-1

I have directly copied the code from a tutorail video that I have been watching and even got a hold of his code files and directly copied and pasted just to make sure but this error keeps popping up. It seems to be limited to this body of

// Checks for a valid email

  else
if
    {
    (!filter_var($email, FILTER_VALIDATE_EMAIL))
        {
        header("Location: ../signup.php?error=invalidmail&uid=" . $username);
        exit();
        }

If you have any input on where I went wrong please help, as I am new at this

closed as off-topic by fuxia Apr 18 at 10:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    php.net/manual/en/control-structures.elseif.php – That's basic PHP. Remove the else or make it elseif if it is part of a larger control structure above it. – leymannx Apr 18 at 8:34
  • You have { after if and this is the cause of the error. See the link that gave leymannx. – nmr Apr 18 at 8:37
1

That code looks completely mangled. Try:

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
   header("Location: ../signup.php?error=invalidmail&uid=" . $username);
   exit();
}

Count up the if and else and make sure they surround the code correctly. Although you can skip the {} when using a single line of code, it's good practice to always add them in, so you can avoid messy, error prone code like this.

if($value = 10) {
   // Your code
} else {
   // Something else
}

Finally, this isn't anything to do with WordPress.

Not the answer you're looking for? Browse other questions tagged or ask your own question.