reel_biggy_fish Posted July 2, 2010 Share Posted July 2, 2010 i have used a tutorial to create a blog - 'http://www.devshed.com/c/a/MySQL/Creating-a-Login-Script-for-a-PHPMySQL-Blogging-System/' and ive got it all working but im having a major problem when i login. when i register on this page - 'http://www.asdesigns.co.uk/LoginScript/register.php' it all registers fine and i can see it all going into my database. the problem is when i login on - 'http://www.asdesigns.co.uk/LoginScript/login.php' i got the username is wrong error. ive added the files in zip file that are to do with the login but i cant seem to work out why i get this error. could someone please advise where this error is. Thanks in advance [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2010 Share Posted July 2, 2010 That script is using password('$pw1') in the registration script but is not doing the same thing when it checks in the login page, so that script never worked and no one cared enough to correct it after it was posted. Also, the script should NOT be using mysql's password() function in the first place. It should be using either md5() or sha() AND it should be doing the same thing in both the register and login script. Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080232 Share on other sites More sharing options...
reel_biggy_fish Posted July 2, 2010 Author Share Posted July 2, 2010 ive changed password($pw1) to md5($pw1) and it puts the 35 character code into the database. could you explain how i would check it against it in the login file please? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080268 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2010 Share Posted July 2, 2010 $query="select * from user where uname='$n' and pw=md5('$p')"; Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080269 Share on other sites More sharing options...
reel_biggy_fish Posted July 2, 2010 Author Share Posted July 2, 2010 I've found out what it actually does. and wouldnt have a clue how to fix it. when you register and put your password in for example 'test' it converts it to md25 and then when you try and login you cant type in 'test' you have to type in the md25 of 'test' so the password would be '49f68a5c8493ec2c0bf489821c21fc3b' when obviously thats not right Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080270 Share on other sites More sharing options...
mattal999 Posted July 2, 2010 Share Posted July 2, 2010 I've found out what it actually does. and wouldnt have a clue how to fix it. when you register and put your password in for example 'test' it converts it to md25 and then when you try and login you cant type in 'test' you have to type in the md25 of 'test' so the password would be '49f68a5c8493ec2c0bf489821c21fc3b' when obviously thats not right Read PFMaBiSmAd's (Thank god for Copy and Paste) post above. To validate the user's login, you simply md5 the password that they typed in the login form and check if the output is the same as the one in the database. Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080287 Share on other sites More sharing options...
reel_biggy_fish Posted July 2, 2010 Author Share Posted July 2, 2010 im sorry but i dont understand what your asking me to do Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080303 Share on other sites More sharing options...
mattal999 Posted July 2, 2010 Share Posted July 2, 2010 Basically replace the old line with this one in login.php: $query="select * from user where uname='$n' and pw=md5('$p')"; Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080321 Share on other sites More sharing options...
reel_biggy_fish Posted July 2, 2010 Author Share Posted July 2, 2010 i did that. but it still gives me an error saying the username and password are wrong. but its because the password isnt the md25 of the text you enter Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080326 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2010 Share Posted July 2, 2010 So, after you changed the register code so that it stored the md5 of the entered password, did you delete any rows from your table and re-register so that the value stored in the table would be updated so that the query in the login code could match the md5 value? Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080332 Share on other sites More sharing options...
reel_biggy_fish Posted July 2, 2010 Author Share Posted July 2, 2010 yer ive finally got it to login but now im having some other troubles. ive got most of it all set up but when i log in as an admin the create a new thread doesnt appear. this is the link i am trying to get at: <? if($_SESSION['level'] == "Admin") {?> <tr> <td width="17%"> </td> <td width="83%"><a href="new_post.php">Create New Thread </a></td> </tr> <? }?> my database table has a field called level and in that field is called Admin but yet i cant seem to see that link. feel free to try out the website: http://www.asdesigns.co.uk/LoginScript/register.php but when you log in and then create a new user and make it an admin from the dropdown menu and then login as that 'admin' it doesnt display the create new thread link. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/206511-login-script-problem-always-saying-incorrect-username/#findComment-1080396 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.