eaglelegend Posted May 15, 2008 Share Posted May 15, 2008 Parse error: syntax error, unexpected '}' in /misc/39/000/171/334/2/user/web/test.eaglelegend.com/login.php on line 23 Sorry for the messy code, its just I am trying to change the site from cookies to sessions, so yeah, I kind of figured how to do that, only thing is, is errors do come with testing things >_<, thats why I set up the test site for temporary use. here is the code: <?php include("header.php"); $username = $_POST['username']; $password = md5($_POST['password']); if($username && $password) { $check = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`=\"$username\" AND `password`=\"$password\"")); if($check == 1) { $_SESSION['ELv2'] = $username; session_register('ELv2'); Header("Location: index.php"); } else { print "Cant set cookie"; } } else { print "Sorry, username/password mismatch!"; } } else { ?> <h2>Login</h2><p> <form action="login.php" method="post"> Username<br> <input type="text" name="username" class="text_box" size="20" value="Username" title="Please enter the Username you registered here with." alt="Please enter the Username you registered here with."><p> Password<br> <input type="password" name="password" class="text_box" size="20" value="password" title="Please enter the Password you registered here with." alt="Please enter the Password you registered here with."><p> <input type="submit" class="text_box" value=" Login " title="Click here to log in." alt="Click here to log in."></form> <? } include("footer.php"); ?> incase you didnt notice, it is login code btw! Quote Link to comment https://forums.phpfreaks.com/topic/105825-parse-error/ Share on other sites More sharing options...
rhodesa Posted May 15, 2008 Share Posted May 15, 2008 change: session_register('ELv2'); to if(session_register('ELv2')){ Quote Link to comment https://forums.phpfreaks.com/topic/105825-parse-error/#findComment-542387 Share on other sites More sharing options...
eaglelegend Posted May 15, 2008 Author Share Posted May 15, 2008 cheers/thanks! that helped alot . good luck with future errors being posted. Quote Link to comment https://forums.phpfreaks.com/topic/105825-parse-error/#findComment-542392 Share on other sites More sharing options...
wildteen88 Posted May 15, 2008 Share Posted May 15, 2008 session_register is depreciated. Do not use this function. Just use $_SESSION['your_var'] = 'somevalue' to set session variables. Also I donot recommend the following: $username = $_POST['username']; $password = md5($_POST['password']); if($username && $password) { This is sloppy in my opinion. I'd do: if(isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = md5($_POST['password']); Quote Link to comment https://forums.phpfreaks.com/topic/105825-parse-error/#findComment-542393 Share on other sites More sharing options...
rhodesa Posted May 15, 2008 Share Posted May 15, 2008 on another note, make sure you run $username through mysql_real_escape_string() before adding it to the mysql query Quote Link to comment https://forums.phpfreaks.com/topic/105825-parse-error/#findComment-542412 Share on other sites More sharing options...
eaglelegend Posted May 15, 2008 Author Share Posted May 15, 2008 as you guys know, I bought the code originally from a rubbish programmer, sorry if that programmer is reading but well, I am trying to make the code alot safer, coding anyway, so whatsthe differance between if(isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = md5($_POST['password']); and the original one? and ok, so yeah as I have and only just started using sessions so, could you explain more about this new one you want me to use instead of the session register? EDIT: Also, how do I change youre " if(session_register('ELv2')){" to the new one you mentioned that is better? Quote Link to comment https://forums.phpfreaks.com/topic/105825-parse-error/#findComment-542420 Share on other sites More sharing options...
BlueSkyIS Posted May 15, 2008 Share Posted May 15, 2008 i suggest that you back up a bit and go through a more recent tutorial on sessions: http://www.tizag.com/phpT/phpsessions.php Quote Link to comment https://forums.phpfreaks.com/topic/105825-parse-error/#findComment-542441 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.