为了账号安全,请及时绑定邮箱和手机立即绑定

PHP注册页面的逆向思维,菜鸟求解惑

PHP注册页面的逆向思维,菜鸟求解惑

PHP
末峰 2017-06-05 23:58:00
<?php<?php header('content-type:text/html;charset=utf-8'); //1.接收数据 $username=$_POST['username']; $password=$_POST['password']; $password1=$_POST['password1']; $email=$_POST['email']; $age=$_POST['age']; $verify=$_POST['verify']; $verify1=$_POST['verify1']; $reUrl="<a href='1-reg.php'>重新填写</a>"; // echo $username,'-',$password,'-',$password1,'-',$email,'-',$age,'-',$verify,'-',$verify1; //2.检测用户名合法性,检测用户名长度 $userLen=strlen($username); if($userLen>=6 && $userLen<=10){     //检测用户名首字母是否是字母开始     // $firstChar=$username{0};     // $ascii=ord($firstChar);     $ascii=ord($username{0});     if(($ascii>=65 && $ascii<=90) || ($ascii>=97 && $ascii<=122)){         //3.检测密码的合法性         $pwdLen=strlen($password);         if($pwdLen>=6 && $pwdLen<=10){             //4.检测两次密码是否一致             if($password===$password1){                 //5.检测邮箱的合法性                 $pos1=strpos($email,'@');                 $pos2=strrpos($email,'@');                 if($pos1!==false){                     //检测@符号是否出现在起始或者结束的位置                     if($pos1!=0 && $pos2!=(strlen($email)-1)){                         //6.检测年龄的合法性                         //检测是否是合法数值                         if(is_numeric($age)){                             //检测年龄范围                             if($age>=1 && $age<=150){                                 //7.检测验证码是否符合规范                                 if($verify===$verify1){                                     // echo '注册成功!!!!';                                     $userInfo=<<<USERINFO                                     <h1>注册成功,信息如下</h1>                                     <table border="1" cellpadding="0" cellspacing="0" width="50%" bgcolor="#abcdef">                                         <tr>                                             <td>用户名</td>                                             <td>{$username}</td>                                         </tr>                                         <tr>                                             <td>邮箱</td>                                             <td>{$email}</td>                                         </tr>                                         <tr>                                             <td>年龄</td>                                             <td>{$age}</td>                                         </tr>                                     </table> USERINFO;                             echo $userInfo;                                 }else{                                     exit("验证码错误,{$reUrl}");                                 }                             }else{                                 exit("年龄范围不符合规范,{$reUrl}");                             }                         }else{                             exit("非法数值,{$reUrl}");                         }                     }else{                         exit("邮箱中的@符号不能出现在起始或者结束位置,{$reUrl}");                     }                 }else{                     exit("邮箱中没有包含@符号,{$reUrl}");                 }             }else{                 exit("两次密码不一致,{$reUrl}");             }         }else{             exit("密码不符合要求,{$reUrl}");         }     }else{         exit("用户名首字母不是以字母开始,{$reUrl}");     } }else{     exit("用户名长度不符合规范,{$reUrl}"); }如何在不改变整体结构的情况下调整局部的逻辑关系,来判断接收的数据是否正确
查看完整描述

4 回答

已采纳
?
仙士可

TA贡献170条经验 获得超132个赞

我第一次见过这么长的if,太他妈难受了

if(验证密码错误){

exit('')

}


if(验证另一个错误){

exit('')

}


这样写不就行了,如果判断错误了,exit直接就退出了页面,至于包这么多层if么


查看完整回答
4 反对 回复 2017-06-06
?
慕圣4558451

TA贡献1条经验 获得超0个赞

看来这娃没学过正则

查看完整回答
反对 回复 2017-06-06
?
qq_歲月靜好不忘初心_0

TA贡献38条经验 获得超6个赞

过于复杂
查看完整回答
反对 回复 2017-06-06
?
子期不遇

TA贡献150条经验 获得超35个赞

这条件判断和提示真人性化!!有时候,你只需要总体概括一下,不需要这么详细的。

查看完整回答
反对 回复 2017-06-06
  • 4 回答
  • 0 关注
  • 1481 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信