<?php //更改密码的编辑界面
//加载文件,判断是否登陆
include('menu.php');
include('head.php');
?>
<form method="post" name="regform" action="gr_ggmm_update.php">
<script type="text/javascript"> //更新前的格式判断
function regcheck()
{
var regpassword=/^[A-Za-z0-9]+$/;
var password1=document.regform.password1.value;
var password2=document.regform.password2.value;
var password3=document.regform.password3.value;
if (!password1.match(regpassword))
{
alert("密码应由英文或数字组成");
document.regform.password1.focus();
return false;
}
if (!password2.match(regpassword))
{
alert("密码应由英文或数字组成");
document.regform.password2.focus();
return false;
}
if (!password3.match(regpassword))
{
alert("密码应由英文或数字组成");
document.regform.password3.focus();
return false;
}
if (password2!=password3)
{
alert("两次密码不一致");
document.regform.password2.focus();
return false;
}
}
</script>
<table width=35% border="0" bordercolor="#0099FF" align="center">
<caption><?php echo $_SESSION['ywclrealname'] ?> 更改密码
</caption>
<tr>
<td width="27%" align="right">原密码:</td>
<td width="40%"><input type="password" name="password1" autofocus></td>
<td width="33%">例:ae4D5c</td>
</tr>
<tr>
<td align="right">新密码:</td>
<td><input type="password" name="password2" ></td>
<td>例:ae4D5c</td>
</tr>
<tr>
<td align="right">新密码:</td>
<td><input type="password" name="password3" ></td>
<td>例:ae4D5c</td>
<tr>
<td align="right"><input type="reset" name="submit2" value="清空" /></td>
<td align="center">
<input type="submit" name="submit" value="更新" onClick="return regcheck()"/>
</td>
<td align="right"> </td>
</tr>
</table>
</form>
<?php
include('foot.php');
?>
PHP+JAVASCRIPT+正则表达式更改密码的实例
最新推荐文章于 2021-09-06 15:17:21 发布
这篇博客展示了如何结合PHP和JavaScript实现更改密码的功能。通过包括'menu.php'和'head.php'文件来处理登录状态,然后提供一个表单让用户输入原密码和两次新密码。JavaScript函数'regcheck()'利用正则表达式验证密码必须由英文或数字组成,并检查新密码的一致性。如果验证失败,将弹出相应警告。最后,表单提交触发'regcheck()'以确保数据正确性。
摘要由CSDN通过智能技术生成