Still working on this script.
I'm trying to add a phone number validator in now.
I know I need to add this:
if ( $phone =~ / ^ \( \d{3} \) \d{3} - \d{4} $ /x )
But I'm not sure where.
Here's the code:
I know I need to add this:
if ( $phone =~ / ^ \( \d{3} \) \d{3} - \d{4} $ /x )
But I'm not sure where.
Here's the code:
Code:
#!/usr/bin/perl -w
use CGI ':standard';
use DBI;
$dbh = DBI->connect("DBI:mysql:s04-it604-s13:localhost", "s04-it604-s13", "PASSWORD");
if (param()) {
$name=param('name'),
$email=param('email'),
$phone=param('phone'),
$time=param('time'),
$homequestion=param('homequestion'),
$selected=param('selected'),
$textarea=param('textarea');
$query = "INSERT INTO estform (name, email, phone, time, homequestion, selected, textarea )
VALUES ( '$name', '$email', '$phone', '$time', '$homequestion','$selected', '$textarea' )";
$rows = $dbh->do($query);
}
if ($rows > 0) {
print redirect(-location=>'[URL unfurl="true"]http://matrix.csis.pace.edu/~s04-it604-s13/Project/thanks.html');[/URL]
}
else {
print header();
print <<EOF
<html><head><title>Inserting into MySQL
</title></head><body>
<h2>Error: INSERT query failed.</h2>
<a href="javascript:history.go(-1)"><h2>Return to Previous Page</h2></a>
</body></html>
EOF
}