2

ハッシュSHA-512を使用して、データベース内の暗号化されたパスワードを使用してフォーム内のパスワードを検証します。私がやろうとしているのは、特にパスワード変更フォーム用です。

フォームとデータベースのパスワードが暗号化されていないかどうかを検証できます...しかし、入力されたパスワードはまだ通常の形式であり、データベース内のパスワードは暗号化されているため、入力されたパスワードがデータベースのパスワードと等しいことを検証できません。

jQuery検証機能を使いたかったのですが…入力したパスワードをデータベースで暗号化して送信する方法にこだわっていました。

4

2 に答える 2

2
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パート(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;
?>
于 2012-03-20T07:25:07.440 に答える
0
function Validate(data)

that is absolutely not what he was asking for ... have you even read his question? Most likely not.

http://jssha.sourceforge.net/

http://pajhome.org.uk/crypt/md5/sha512.html

于 2012-03-21T07:04:39.173 に答える