2

This is my php code

<?php   
    if ($_POST['submit']){
        if (!$_POST['email']) $error.="</br>Please enter your email address";
        else if !(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) $error = "</br>Please enter a valid email address.";

     if (!$_POST['password']) $error.="</br>Please enter a password.";

   if($error) echo "There were error(s)".$error;
  }
?>

I don't find any mistake there. But it is showing this error

Parse error: syntax error, unexpected '!', expecting '(' in C:\xampp\phpMyAdmin\abc\projects\s_diary.php on line 5

I am not much experienced in php. So, please help me...

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98

1 Answers1

1

The first else if is missing parentheses around its if-expression, as in:

else if ( !(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) ) ...
        ^                                                       ^
        |                                                       |
Jim Garrison
  • 85,615
  • 20
  • 155
  • 190