Jump to content

[SOLVED] login issues when using Sha


maztrin

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.