Zoofu Posted July 30, 2009 Share Posted July 30, 2009 <?php session_start(); include "./global.php"; if($_SESSION['uid']){ echo "You are already logged in, <a href=\"./logout.php\">logout</a>?\n"; }else { if(!$_POST('submit')){ echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"./login.php\">\n"; echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n"; echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\"></td></tr>\n"; echo "</form></table>\n"; }else { $user = mss($_POST['username']); $pass = $_POST['password']; if($user && $pass){ $sql = "SELECT id FROM `users` WHERE `username`='".$user."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) > 0) { $sql2 = "SELECT id FROM `users` WHERE `username`='".$user."' AND `password` ='".md5($pass)."'"; $res2 = mysql_query($sql2) or die(mysql_error()); if(mysql_num_rows($res2) > 0){ $row = mysql_fetch_assoc($res2); $_SESSION['uid'] = $row['id']; echo "You have logged in successfully!\n"; }else { echo "Username or password are incorrect!\n"; } }else { echo "The Username you supplied does not exist!\n"; } }else { echo "You must fill in all fields!" } } ?> Why is this giving me: Parse error: syntax error, unexpected '{' in ----------- on line 26 Link to comment https://forums.phpfreaks.com/topic/168137-parse-error-why/ Share on other sites More sharing options...
phpSensei Posted July 30, 2009 Share Posted July 30, 2009 try <?php if($_SESSION['uid']){ echo "You are already logged in, <a href=\"./logout.php\">logout</a>?\n"; }else { if(!$_POST('submit')){//1 echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"./login.php\">\n"; echo "<tr><td>Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n"; echo "<tr><td>Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n"; echo "<tr><td colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\"></td></tr>\n"; echo "</form></table>\n"; }else { $user = mss($_POST['username']); $pass = $_POST['password']; if($user && $pass){ $sql = "SELECT id FROM `users` WHERE `username`='".$user."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) > 0) { $sql2 = "SELECT id FROM `users` WHERE `username`='".$user."' AND `password` ='".md5($pass)."'"; $res2 = mysql_query($sql2) or die(mysql_error()); if(mysql_num_rows($res2) > 0){ $row = mysql_fetch_assoc($res2); $_SESSION['uid'] = $row['id']; echo "You have logged in successfully!\n"; }else { echo "Username or password are incorrect!\n"; } }else { echo "The Username you supplied does not exist!\n"; } }else { echo "You must fill in all fields!" } } }//1 ?> Link to comment https://forums.phpfreaks.com/topic/168137-parse-error-why/#findComment-886780 Share on other sites More sharing options...
Zoofu Posted July 30, 2009 Author Share Posted July 30, 2009 Thanks for quick reply, but now: Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/zoofune1/public_html/Htdocs/test.php on line 36 Link to comment https://forums.phpfreaks.com/topic/168137-parse-error-why/#findComment-886785 Share on other sites More sharing options...
Zoofu Posted July 30, 2009 Author Share Posted July 30, 2009 I fixed it but now.. Fatal error: Function name must be a string in /home/zoofune1/public_html/Htdocs/test.php on line 6 Link to comment https://forums.phpfreaks.com/topic/168137-parse-error-why/#findComment-886788 Share on other sites More sharing options...
phpSensei Posted July 30, 2009 Share Posted July 30, 2009 Thanks for quick reply, but now: Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/zoofune1/public_html/Htdocs/test.php on line 36 $user = mss($_POST['username']); whats this? edit: your ELSE at the very top isnt closed post the updated scritp Link to comment https://forums.phpfreaks.com/topic/168137-parse-error-why/#findComment-886789 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.