Re: preg question
| From: | John Nichel | Date: | Thu, 13 Nov 2003 20:09:24 +0000 |
| Subject: | Re: preg question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169554@lists.php.net to get a copy of this message | ||
Jake McHenry wrote:
Yes, you have to escape the period. If you're just checking to see if there's an at symbol and a period, you don't really need preg_match_all if ( ! preg_match ( "/@/", $email ) ) { // No @ symbol } if ( ! preg_match ( "/\./", $email ) ) { // No period } -- By-Tor.com It's all about the Rush http://www.by-tor.com-----Original Message----- From: Jake McHenry [mailto:linux@nittanytravel.com] Sent: Thursday, November 13, 2003 2:50 PM To: php-general@lists.php.net Subject: [PHP] preg question 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'] != "") {I think I got it, I was just messing with the code, and added a slash before the ., and it seems to work. Is this the correct way to handle this?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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php