-1

I'm actually learning PHP but I found this error while running

Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\lols.php on line 13

Can't see my error ¿Would you like to help me?

<!DOCTYPE HTML> 
<html>
<head>
    <title>PHP</title>
</head>
<body>

    <?php 


    $name = $email = $gender = ""

    if ($_SERVER["REQUEST_METHOD"] == "POST"){

        $name = testdata($_POST["name"]);
        $email = testdata($_POST["email"]);
        $gender = testdata($_POST["gender"]);
    }

    function testdata($data){

        $data = trim($data);
        $data = stripcslashes($data);
        $data = htmlspecialchars($data);

        return $data;

    }
     ?>
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">

        Name:   <input type="text" name="name">
        E-mail: <input type="text" name="email">

        Gender: <input type="radio" name="gender" value="male"> male
                <input type="radio" name="gender" value="female"> female
        <input type="submit" name="submit" value="Submit"> 
    </form>



  </body>
  </html>
Jerry Stratton
  • 3,287
  • 1
  • 22
  • 30
Horacio Garza
  • 45
  • 2
  • 7
  • I would suggest to learn debugging your code. If you can not find the error , you can comment lines out with: // and larger part of code in between: /* */ http://php.net/manual/en/language.basic-syntax.comments.php – Fin Aug 26 '15 at 18:24

2 Answers2

3

End the line with ; (semicolon)

$name = $email = $gender = "";

Documentation: http://php.net/manual/en/language.basic-syntax.instruction-separation.php

schellingerht
  • 5,726
  • 2
  • 28
  • 56
2

You are missing a "semicolon":

$name = $email = $gender = "";
JPJens
  • 1,185
  • 1
  • 17
  • 39