The period is a modifier within the expression (see manual on "pattern
syntax" link below).  You need to escape it with a back slash:

\.

http://www.php.net/manual/en/pcre.pattern.syntax.php

--
Kevin


-----Original Message-----
From: Jake McHenry [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 13, 2003 12:50 PM
To: [EMAIL PROTECTED]
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'] != "")
    {
      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 . "&nbsp;&nbsp;&nbsp;&nbsp;" . $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 . "&nbsp;&nbsp;&nbsp;&nbsp;" . $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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to