Hey guys, im pretty new to PHP but has a background on C Programming. I have a really, really ridiculous problem. This is about the MD5 encryption which I use in a login page. I got the code from phpmyeasy and this is what the md5 encryption source code looks like:
$encrypted_mypassword=md5($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$encrypted_mypassword'";
$result=mysql_query($sql);
This code is correct. But the problem is whenever I use the correct login details, it says my password is wrong. I have asked my friend who happens to be a pro at PHP and he says the code is correct. I have an old working PHP login page where the MD5 encryption works and I compared, this is what the code looks like:
$
mypassword=md5($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='
$mypassword'";
$result=mysql_query($sql);
This code works, as you can see in the bolded part, I changed the variable $encrypted_mypassword to $mypassword. This works and it makes me wonder why $encrypted_mypassword doesnt work with it. Does anyone have a clue why is this happening?
I have checked everything from my databases and even initiated $encrypted_mypassword at the start of the code but still it wont work.