Jump to content

Recommended Posts

I have a login page which uses the same md5 encryption to check if the password is correct and also on the "change password" page which also md5 encrypts the input to see if it matches the database, how ever the same word comes out with two different md5 results.

 

I am getting it right because i logged in using the password and it lets me login which works fine... so i paste that exact same password to my change password page where it asks for current password to continue, and some how the md5 password result is totally different to what is in the database, yet the login script creates the correct one..... i don't get why... this is what i have:

 

<?php
$old = md5(strtolower(mysql_real_escape_string($_POST['OldPass']))); // the password currently
$pass = strtolower(mysql_real_escape_string($_POST['Pass'])); //the new password not encrypted
$npass = md5($pass); // new password encrypted
$npass2 = strtolower(mysql_real_escape_string($_POST['Pass2'])); // re-enter passwords make sure its correct
$npass2 = md5($npass2); //encrypt it to see if it matches $npass

$check = mysql_query("SELECT UserID FROM users WHERE UserID='{$_SESSION['Current_User']}' AND Password='$old'")
	Or die(mysql_error());
If(mysql_num_rows($check)>0){
Echo 'success';
}Else{
Echo 'failed';
}
?>

 

As you can guess i get Failed.

 

Now on mylogin page i have this:

 

<?php
$Password = md5(strtolower(mysql_real_escape_string($_POST['Password'])));
$Username = strtolower(mysql_real_escape_string($_POST['Username']));
$check2 = mysql_query("SELECT UserID,Password FROM users WHERE Username='$Username'")
Or die(mysql_error());
$row = mysql_fetch_assoc($check2);
If($row['Password'] == $Password){
Echo 'success';
	}Else{
echo 'failed';
	}
?>

 

As you can probably guess it says "success"... which is what is meant to happen.. so why do you think the first script is not producing the same md5 result?

Link to comment
https://forums.phpfreaks.com/topic/159774-md5-different-results-on-same-input/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.