admin管理员组

文章数量:1431726

Closed. This question is off-topic. It is not currently accepting answers.

Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?

Closed 6 years ago.

Improve this question

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. This question is off-topic. It is not currently accepting answers.

Questions that are too localized (such as syntax errors, code with restricted access, hacked sites, hosting or support issues) are not in scope. See how do I ask a good question?

Closed 6 years ago.

Improve this question

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

Share Improve this question edited Apr 18, 2019 at 10:36 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Apr 18, 2019 at 8:27 John StewardJohn Steward 1 2
  • 2 php/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. – norman.lol Commented Apr 18, 2019 at 8:34
  • You have { after if and this is the cause of the error. See the link that gave leymannx. – nmr Commented Apr 18, 2019 at 8:37
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: