Jump to content

Epicular

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Epicular

  1. Thanks, adding the semicolons fixed the issue. Man, I knew it would've been a stupid mistake.
  2. I am very new to PHP (and forms in general) and I am using the PHP tutorial on w3schools.com to make a simple form for the user to fill out and get checked for errors. I am adapting the code to make an account registration system but there is a syntax error somewhere in the code and I can't find it. Here is my code: <!DOCTYPE html><html><head><style>.error {color: #FF0000;}</style></head><body><?php// define variables and set to empty values$username = $email = $password = $password = "";$nameErr = $emailErr = $passErr = $passtErr = "";if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["username"])) { $nameErr = "Error: All fields required"} else { $username = test_input($_POST["username"]);} if (empty($_POST["email"])) { $emailErr = "Error: All fields required"} else { $email = test_input($_POST["email"]);} if (emtpy($_POST["password"])) { $passErr = "Error: All fields required"} else { $password = test_input($_POST["password"]);} if (empty($_POST["passwordt"])) { $passtErr = "Error: All fields required"} else { $passwordt = test_input($_POST["passwordt"]);} }function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data;}?><h3>Account Sign-up</h3><p><span class="error">All fields required.</span></p><form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Username: <input type="text" name="username"> <span class="error"> <?php echo $nameErr;?></span><br> The name you will be known by.<br><br>E-mail: <input type="text" name="email"><span class="error"> <?php echo $emailErr;?></span><br> Used for password recovery.<br><br> Password: <input type="password" name="password"><span class="error"> <?php echo $passErr;?></span><br>Minimum of 3 characters. Please don't make it stupid.<br><br>Confirm Password:<input type="password" name="passwordt"><span class="error"> <?php echo $passtErr;?></span><br> Don't type in a different password.<br><br> <input type="submit" name="submit" value="Submit"></form></body></html> Here is the actual error received when initially running the code: Parse error: syntax error, unexpected '}' in /home/doubl140/public_html/formtest.php on line 16
×
×
  • Create New...