即日起在codingBlog上分享您的技术经验即可获得积分,积分可兑换现金哦。

第四次PHP作业项目正则(Regular )

编程语言 aa8869138 19℃ 0评论



header(‘content-Type:text/html;charset=UTF-8’);


$post = $_POST;


$name=isset($post[“username”])?$post[‘username’]:exit(“还想耍我?滚回注册菜单。”);


$name = empty($post[“username”])?exit(“你根本输都没输用户名”):$post[“username”];


$rulename=”/[a-zA-Z]\w{6,10}/”;


$username = preg_match($rulename, $name)?htmlspecialchars(trim($name)):exit(“你这叫用户名?首个要字母,长度6-10.”);


//echo “用户名:”.$username.”;”;


//echo “
“;


$pass = empty($post[“password”])?exit(“你根本输都没输密码”):$post[“password”]; 


$rulepass=”/[a-zA-Z][a-zA-Z_!@#]{6,10}/”;


$password = !preg_match($rulepass, $pass)?exit(“你这密码太费劲了?首个要字母,长度6-10.”):htmlspecialchars(trim($pass));


$repass = $password == $post[“password1”]?$post[“password1”]:exit(“你猜是什么问题?”);


//echo “密 码:”.$password.”;”;


//echo “
“;








$tel = empty($post[“tel”])?exit(“手机号你都能不写?”):$post[“tel”];


$usertel=”/^(13[0-9]|14[57]|15[0-9]|18[0-9])\d{8}$/”;


$tele = !preg_match($usertel, $tel)?exit(“你确定这号打得通?”):htmlspecialchars(trim($tel));


//echo “手机号:”.$tele.”;”;


//echo “
“;


//echo “性 别:”.$post[“sex”].”;”;


//echo “
“;


$ema = empty($post[“email”])?exit(“你连个邮箱都没?”):$post[“email”];


$ruleemail=’/^\w+([+-.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/’;


$email = !preg_match($ruleemail,$ema)?exit(“连个邮箱都不好好写”):htmlspecialchars(trim($ema));


echo “验证成功”;






















转载请注明:CodingBlog » 第四次PHP作业项目正则(Regular )

喜欢 (0)or分享 (0)
发表我的评论
取消评论

*

表情