maztrin Posted March 11, 2009 Share Posted March 11, 2009 hi, i have created a simple registration and login system where i have used sha to encrypt the password when it goes into mysql i can create a new user just fine and the password saved in mysql is for exameple: 'e6f2bcf372ca793b829a' but when it comes to logging in a user it does not recognize the password. unless i type in the exact value that was created when using SHA. so i figured there was somethign wrong with the way i was using sha my code: register.php $query = "SELECT ID FROM users WHERE email='$emailadd' "; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { $query = "INSERT INTO users(username, email, password,) VALUES ('$username', '$emailadd',SHA('$pass') )"; $result = @mysql_query ($query); //rest of my code and login.php $query = "SELECT ID, username FROM users WHERE email='$emailladd' AND password=SHA('$pass')"; $result = @mysql_query ($query); $row = mysql_fetch_array($result, MYSQL_NUM); //rest of my code in my mysql database the password field settings are: type: Char, size: 20 am i not supposed to be using sha again in the login form? any help would be appreciated on this thanks Link to comment https://forums.phpfreaks.com/topic/148999-solved-login-issues-when-using-sha/ Share on other sites More sharing options...
Mchl Posted March 11, 2009 Share Posted March 11, 2009 SHA is longer than 20 chars (40 IIRC) Link to comment https://forums.phpfreaks.com/topic/148999-solved-login-issues-when-using-sha/#findComment-782357 Share on other sites More sharing options...
redarrow Posted March 11, 2009 Share Posted March 11, 2009 sha1 hash is 40 characters long. <?php echo SHA1('redarrow'); ?> Link to comment https://forums.phpfreaks.com/topic/148999-solved-login-issues-when-using-sha/#findComment-782360 Share on other sites More sharing options...
revraz Posted March 11, 2009 Share Posted March 11, 2009 So check that your DB field allows for 40 characters. Chances are it's getting cut off. Link to comment https://forums.phpfreaks.com/topic/148999-solved-login-issues-when-using-sha/#findComment-782365 Share on other sites More sharing options...
maztrin Posted March 11, 2009 Author Share Posted March 11, 2009 man alive! i can believe what a dunce i was being...it was getting cut off as well thanks guys all sorted Link to comment https://forums.phpfreaks.com/topic/148999-solved-login-issues-when-using-sha/#findComment-782371 Share on other sites More sharing options...
redarrow Posted March 11, 2009 Share Posted March 11, 2009 hahahahahahahahaha Link to comment https://forums.phpfreaks.com/topic/148999-solved-login-issues-when-using-sha/#findComment-782373 Share on other sites More sharing options...
revraz Posted March 11, 2009 Share Posted March 11, 2009 Easy mistake to make. Link to comment https://forums.phpfreaks.com/topic/148999-solved-login-issues-when-using-sha/#findComment-782459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.