Reputation: 31
Validate password in form with encrypted password in database using hash SHA-512 what I’m trying to do is specifically for a change password form.
I can validate if the password in form and in database are not encrypted... But I fail to validate that entered password is equal to database password because the entered password is still in normal form, and the pasword inside database is the encrypted one.
I wanted to use jQuery validation function… But stuck with how to solve by encrypting entered password with database before submiting.
Upvotes: 2
Views: 1096
Reputation: 1
function Validate(data)
that is absolutely not what he was asking for ... have you even read his question? Most likely not.
http://pajhome.org.uk/crypt/md5/sha512.html
Upvotes: 0
Reputation: 2005
function Validate(data)
{
if(data==true)
{
//submit the form
}
else
{
//dont submit the form. Throw an error/alert
return false;
}
}
//when the form is submitted
$("#yourForm").submit(function()
{
var p=$("#oldPassword").val();
$.post("validate.php",{oldpass:p},Validate);
});
PHP Part (validate.php)
<?php
$oldpassword=$_POST['oldpass'];
//encrypt $oldpassword to md5 or anything as per your requirement
//and compare it with the encrypted password available in the database
if($oldpassword==$dbpass)
{
$status=true;
}
else
{
$status=false;
}
echo $status;
?>
Upvotes: 2