服务端通过生成随机数并设置session:
session_start();
$_SESSION["tk"] = substr(md5(time()),0,6);
<script type="text/javascript" src="/md5.js"></script>
<script type="text/javascript">
function md5(form)
{
var session = "<?php echo $_SESSION['tk']; ?>";
form.Password.value=hex_md5(form.Password.value.session)
}
</script>
修改表单提交调用JS,提交type要为submit,不然无效。
<form id="Form_Login" method="post" action="login.php" onsubmit="md5(this)">
标签:php