I am currently creating a page to allow a user to change their password. I have a field which the user will enter their current password into and I am then using javascript to check whether this is the correct password. My passwords are encrypted using md5 and so I need to incorporate this into the javascript function. I have tried but unfortunately cannot get the correct value for the encrypted password.
My javascript code is as follows...
Code:
function verifyCurrentPassword(){
//Gain the hashed password that is in the database
var password;
<?php
print "password='" .$password. "';\n";
?>
//Find the password that the user has entered as the current password
var hashedpassword;
var currentpassword = document.getElementById("currentpassword").value;
<?php
print "hashedpassword='" .md5("currentpassword"). "';\n";
?>
if(password == hashedpassword){ alert("passwords are the same"); }
}