0

I have plesk on my vps and upgraded php as in the title and now my php form script has stopped working. It gets to the email validation and returns email invalid. It appears to get to here ok - Tried multiple different preg_match strings - any ideas anyone.

 if (!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email)) {
  echo "<p>It appears you entered an invalid email address</p><p><a href='javascript: history.go(-1)'><font color=\"orange\">Click here to go back</font></a></p>"; 
} 

 elseif (!trim($name)) { 
  echo "<p>Please go back and enter a Name</p><p><a href='javascript: history.go(-1)'><font color=\"orange\">Click here to go back</font></a></p>"; 
}  

 elseif (!trim($email)) { 
  echo "<p>Please go back and enter an Email</p><p><a href='javascript: history.go(-1)'><font color=\"orange\">Click here to go back</font></a></p>"; 
} 

 elseif (!trim($telephone)) { 
  echo "<p>Please go back and enter a Telephone number</p><p><a href='javascript: history.go(-1)'><font color=\"orange\">Click here to go back</font></a></p>"; 
}

 elseif (!trim($eventaddress)) { 
  echo "<p>Please go back and enter the Event address number</p><p><a href='javascript: history.go(-1)'><font color=\"orange\">Click here to go back</font></a></p>"; 
}
Spudley
  • 166,037
  • 39
  • 233
  • 307
  • 2
    You might want to consider using FILTER_VALID_EMAIL instead of a home-rolled regex. http://php.net/manual/en/filter.filters.validate.php Also what debugging have you attempted? – GordonM Aug 05 '13 at 14:47
  • www.php.net/filter_var and use `if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ // complain about error }` – N.B. Aug 05 '13 at 14:47

0 Answers0