私は 2 つの PHP ファイルを持っており、login.php
暗号化を使用し、次のサイトのログイン メカニズムを使用しています
。そこに登録コードの一部が表示されますが、登録フォームを作成し、サイトの登録フォームを「process_registration」に変更しました。 register.php
sha512
ではlogin.php
、フォームは : を使用して送信されonclick="formhash(this.form,this.form.password);"
ますformhash()
: (from forms.js
)
function formhash(form, password) {
// Create a new element input, this will be out hashed password field.
var p = document.createElement("input");
// Add the new element to our form.
form.appendChild(p);
p.name = "p";
p.type = "hidden";
p.value = hex_sha512(password.value);
// Make sure the plaintext password doesn't get sent.
password.value = "";
// Finally submit the form.
form.submit();
}
したがって、登録とログインで同じ暗号化プロセスを使用するには、登録フォームでもこのメソッドを使用する必要がprocess_registration.php
ありますが、フォームに到達すると (すべての正しいパラメーターを使用してフォームに到達すると)、p
var は機能しませんに存在しますが、フォームPOST
とフィールドはlogin.php
まったく同じです。 login
process_login.php
register.php
process_registration.php
登録ファイルのフォームは次のとおりです。
<script type="text/javascript" src="sha512.js"></script>
<script type="text/javascript" src="forms.js"></script>
<form action="process_registration.php" method="post" name="register_form">
Username : <input type="text" name="username" /><br />
Name : <input type="text" name="name" /><br />
Email: <input type="text" name="email" /><br />
Password: <input type="password" name="password" id="password"/><br />
<input type="button" value="Register" onclick="formhash(this.form,this.form.password);" />
</form>