这个程序实现的是用html' target='_blank'>正则表达式实现登录验证的一个Demo
<1>:<?php if(isset($_POST["sub"])){ $text=$_POST["text"]; $patten='^[0-9]*$'; if(!preg_match($patten,$text,$x)){ echo"<script>alert('用户没有输入数字');</script>";}else{ if($x<1){ $y=$x; echo "y=".$y."<br>"; }else if($x<10){ $y=2*$x-1; echo "y=".$y."<br>"; }else{ $y=3*$x-11; echo "y=".$y."<br>"; } }?><html><head></head><body><form method='post'>请输入信息:<input type="text"name="text"><input type="submit"name="sub"value="提交"></form></body></html><2>:<html><head></head><body><form method='post'>注册账号:<input type="text"name="aNum"><br>登录密码:<input type="password"name="pwd"><br>重复密码:<input type="password"name="rPwd"><br>邮箱地址:<input type="text"name="email"><br>手机号码:<input type="text"name="tel"><br><input type="submit"name="sub"value="注册"><?php if(isset($_POST["sub"])){ $aNum=$_POST["aNum"]; $pwd=$_POST["pwd"]; $rPwd=$_POST["rPwd"]; $email=$_POST["email"]; $tel=$_POST["tel"]; $patten1="^w+(.[w-]+)*@[w-]+(.[w-]+)+$";//验证邮箱 $patten2="[0-9]{11}";//11位数字组成,验证手机号码 $patten3="[a-zA-Z_-ÿ][a-zA-Z0-9_-ÿ]*"//验证账号 if(!preg_match($patten3,$aNum)){ echo"<script>alert('账号格式不对');</script>"; }else{ if($pwd.length<6){ echo"<script>alert('密码格式不对');</script>"; }else{ if(!preg_match($patten,$email)){ echo"<script>alert('email格式不正确');</script>"; }else{ if(!preg_match($patten2,$tel)){ echo"<script>alert('手机号码格式不正确');</script>"; }else{ if(strlen($pwd)!=strlen($rPwd)){ echo"<script>alert('两次密码不一致');</script>"; }else{ echo"用户您好!您的账号为:".$aNum.",密码为:".$pwd.",邮箱为:". $email.",手机号码为:".$tel; } } } }} ?></form></body></html>PHP编程
郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。
新闻热点
疑难解答