<html>
<title>Register</title>
<head>
<script type="text/javascript" src="sha512.js"></script>
<script>
function formhash(form, password, confirm_password) {
if(password.value==confirm_password.value){
var p = document.createElement("input");
p.name = "p";
p.type = "hidden";
p.value = hex_sha512(password.value);
password.value = "";
form.appendChild(p);
form.submit;
return true;
}
else{
header('Location: ./register.php?error=1');
return false;
}
}
</script>
</head>
<body>
<form action="process_register.php" method="post" name="register_form">
Username: <input type="text" name="username"/></br>
Email: <input type="text" name="email"/></br>
Password: <input type="password" id="password" name="password"/></br>
Confirm Password: <input type="password" id="confirm_password" name="confirm_password"/></br>
<input type="submit" value="Register" onclick="return formhash(this.form, this.form.password, this.form.confirm_password);"/>
</form>
</body>
</html>
大家好,我对网络编码比较陌生。我正在尝试做一个注册页面,但是 onclick 根本不会触发 formhash 功能。有人可以启发我吗?谢谢!