preg question
| From: | Jake McHenry | Date: | Thu, 13 Nov 2003 19:50:02 +0000 |
| Subject: | preg question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-169548@lists.php.net to get a copy of this message | ||
Hi all,
I am trying to do a simple validation of an email address being
submitted. I have the @ sign being validated, but I can't get the
period to work.. Can someone help me out?
Here's my code..
if ($_POST['Travel_Request_Email_Address'] != "")
{
if (preg_match_all("/(@)/",
$_POST['Travel_Request_Email_Address'], $match) != 1)
{
$errorcount++;
$error = $error . " " . $errorcount
.")
<font color=\"red\">Email Address</font> field does not contain @<br>
\n";
}
else if (preg_match_all("/(.)/",
$_POST['Travel_Request_Email_Address'], $match) < 1)
{
$errorcount++;
$error = $error . " " . $errorcount
.")
<font color=\"red\">Email Address</font> field does not contain .<br>
\n";
}
else
{
$_SESSION['Travel_Request_Email_Address'] =
$_POST['Travel_Request_Email_Address'];
}
}
else
{
$errorcount++;
$error = $error . " " . $errorcount .")
<font color=\"red\">Email Address</font> field is empty<br>\n";
}
Thanks,
Jake McHenry
Nittany Travel MIS Coordinator
http://www.nittanytravel.com