Hello,
I have just stared learning about patterns, hoping to be able to write my own form validation script. I very new with php and was wondering if any of you could point out why my script doesn't work. It's two pages, test.html and process.php.
test.html
<form action="process.php" method="get">
<p>First Name:
<input type="text" name="first_name" />
</p>
<p>Last Name:
<input type="text" name="last_name" />
</p>
<p>Email:
<input type="text" name="email" />
</p>
<p>Message:
<input type="text" name="message" />
</p>
<p>
<input name="Submit" type="submit" value="Sumbit" />
</p>
</form>
process.php
<php?
$first_name = $_GET["first_name"];
$last_name = $_GET["last_name"];
$email = $_GET["email"];
$message = $_GET["message"];
if (!preg_match("[A-Za-z]", $first_name));
{
echo "\nFirst Name field was incorrect\n";
}
if (!preg_match("[A-Za-z]", $last_name));
{
echo "\nLast Name field was incorrect\n";
}
if (!preg_match("/^[a-z0-9_-]+(\.[a-z0-9_-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\.)+([a-z]{2,4})$/", $email));
{
echo "\nEmailfield was incorrect\n";
}
if (!preg_match("[A-Za-z]", $message));
{
echo "\nMessage field was incorrect";
}
?>
When I submit the information, I get this output no matter what I put into the text boxes, even if it matches the patterns.
First Name field was incorrect
Last Name field was incorrect
Emailfield was incorrect
Message field was incorrect
Anyone know what I'm doing wrong? I'd appreciate the help. :o
Later on I'll be using something like this to enter info into my db, but for now I'm just trying to figure out form validation.