topflight Posted October 24, 2008 Share Posted October 24, 2008 Hi all I am trying to create a log in system with different user acesses(i.e 1=normal 2=admin and etc...). Well I am now receiving an error which says: Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\logincheck.php on line 30 I look at like 30 and I can't find nothing wrong. I am still new to php so please bare with me. Here is my login in system code. login.php <style type="text/css"> .idBox { width:50px; } .passwordBox { width:80px; } </style> </head> <body> <table border="0" align="center"> <form action="logincheck.php" method="post"> <tr> <td align="center">ID:</td><td align="center">ASA<input type="text" name="login" class="idBox"></td> </tr> <tr> <td align="center">Password:</td><td align="center"><input type="password" name="pwd" class="passwordBox"></td> </tr> <tr> <td></td><td align="center"><input type="submit" name="submit" value="Login"></td> </tr> </table> </form> <body> logincheck.php <?php session_start(); header("Location: crewcenter.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <?php include 'db.php'; ?> <?php $login = $_POST['login']; $pwd = $_POST['pwd']; ?> <?php if($_POST[submit]){ if((!$login) || (!pwd)){ echo'Please insert all of the information'; include'login.php'; } else { $sql = "SELECT * FROM `pilots` WHERE login = `$login` AND pwd = `$pwd`"; $query = mysql_query($sql) or die mysql_error()); $pcheck = mysql_num_rows($query); if($pcheck==0){ echo'Incorrect Login Information'; } else { session_register('login'); $_SESSION['login'] = $login; session_register('pwd'); $_SESSION['pwd'] = $pwd; session_register('fname'); $_SESSION['fname'] = $fname; session_register('lname'); $_SESSION['lname'] = $lname ; } } ?> crewcenter.php <?php session_start(); session_checker(); function session_checker(){ if(!session_is_registered('login')){ include 'login.php'; exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> This is line 30 where I am receiving the problems. <?php $query = mysql_query($sql) or die mysql_error());?> Also please give me any suggestions on my login code. Thanks Link to comment https://forums.phpfreaks.com/topic/129961-trying-to-create-a-login-system/ Share on other sites More sharing options...
GKWelding Posted October 24, 2008 Share Posted October 24, 2008 line 30 of logincheck.php should read $query = mysql_query($sql) or die (mysql_error()); not $query = mysql_query($sql) or die mysql_error()); Link to comment https://forums.phpfreaks.com/topic/129961-trying-to-create-a-login-system/#findComment-673719 Share on other sites More sharing options...
topflight Posted October 24, 2008 Author Share Posted October 24, 2008 thanks but... when I type the correct information from the database in the form it goes to crewcenter.php but instead of displaying a white page since the password and login is write it just keep reshowing the login form. I wonder why is that happening. Link to comment https://forums.phpfreaks.com/topic/129961-trying-to-create-a-login-system/#findComment-673726 Share on other sites More sharing options...
GKWelding Posted October 24, 2008 Share Posted October 24, 2008 put this in crewcenter.php instead... <?php session_start(); session_checker(); function session_checker(){ if(!session_register('login')){ include 'login.php'; exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/129961-trying-to-create-a-login-system/#findComment-673733 Share on other sites More sharing options...
PFMaBiSmAd Posted October 24, 2008 Share Posted October 24, 2008 The following line in logincheck.php is unconditionally redirecting to crewcenter.php - header("Location: crewcenter.php"); Programs only do what the code tells them to do. Why do you have that line of code near the start of logincheck.php? Link to comment https://forums.phpfreaks.com/topic/129961-trying-to-create-a-login-system/#findComment-673744 Share on other sites More sharing options...
topflight Posted October 24, 2008 Author Share Posted October 24, 2008 Well because I am still new to php and and I thought that a session always had to have a header. And my secure Area is crecenter.php thats why I put that in in teh Location spot. Link to comment https://forums.phpfreaks.com/topic/129961-trying-to-create-a-login-system/#findComment-673792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.