joecooper Posted May 5, 2008 Share Posted May 5, 2008 i get the unexpected } on line 20, but cant see whats wrong as it should be there to end the IF command <?php if (isset($_POST['submit'])){ //if page was accessed via submit $username=$_POST['username']; //set username varible to the username they entered $password=$_POST['password']; //set password varible to the password they entered if($username){ //check that username feild was entered if($password){ //check that password feild was entered $password=md5("123$password"); //encrypt thier password to compare $result=mysql_query($sql); //If the user gets to here, then they have typed both a username and password, so we may now go onto finding out if they excist in the DB $sql="SELECT * FROM users WHERE (username='$username') AND password='$password'"; //get rows where the username feild matches the username feild in the database with same password $result=mysql_query($sql); if (mysql_num_rows($result) > 0){ //if the number of rows returned is more then 1, then the details excist echo("Welcome $username!, you are now logged in!"); $_SESSION['loggedin']="TRUE"; $_SESSION['username']=$username } }else{ echo("Please enter your password"); } }else{ echo("Please enter your username"); } } //page freshly accessed... do nothing! ?> <form method="POST" action="register.php"> Username: *<input type="text" name="username" size="20" value="<?php echo $username; ?>" maxlength="255"><br> Password: *<input type="password" name="password" size="20" value="" maxlength="255"><br> <input type="submit" name="submit" value="Login!"> </form> Link to comment https://forums.phpfreaks.com/topic/104146-syntax-error-unexpected/ Share on other sites More sharing options...
joecooper Posted May 5, 2008 Author Share Posted May 5, 2008 noticed i missed the ; at the end of line 19. oops! Link to comment https://forums.phpfreaks.com/topic/104146-syntax-error-unexpected/#findComment-533189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.