<?php
header ( 'content-type:text/html;charset=utf-8' );
$glue = range ( chr ( 65 ), chr ( 90 ), 1 );
$glue = array_merge ( $glue, range ( chr ( 97 ), chr ( 122 ), 1 ) );
$glue = array_merge ( $glue, range ( chr ( 48 ), chr ( 57 ), 1 ) );
$string = implode ( $glue, '' );
$code = null;
for($i = 0; $i < 4; $i ++) {
$code .= '<span style="color:rgb(' . mt_rand ( 0, 255 ) . ',' . mt_rand ( 0, 255 ) . ',' . mt_rand ( 0, 255 ) . ')">' . $string {mt_rand ( 0, strlen ( $string ) - 1 )} . '</span>';
}
?>
<!DOCTYPE html>
<html>
<head>
<title>注册页面</title>
</head>
<body>
<form action="doAction.php" method="post" name="signup" id="signup">
<div class="lr_e">
<label><span class="err" style="display: none" id="username_err"></span>用户名</label>
<div class="txt">
<input class="ef" maxlength="11" type="text" autocomplete="off" id="username" name="username" placeholder="用户名首字母必须以字母开始" value="abcdef">
</div>
</div>
<div class="lr_e">
<label> <span class="err" style="display: none" id="pwd_err"></span> 密码
</label>
<div class="txt">
<input class="ef" autocomplete="off" maxlength="16" type="password" id="userpwd" name="password" placeholder="密码必须是6-10位字母/数字/符号组合" value="123456">
</div>
</div>
<div class="lr_e">
<label><span class="err" style="display: none" id="pwdcfm_err"></span>确认密码</label>
<div class="txt">
<input class="ef" type="password" autocomplete="off" id="password1" name="password1" maxlength="16" placeholder="请输入和上面相同的密码" value="123456">
</div>
</div>
<div class="lr_e">
<label><span class="err" style="display: none" id="email_err"></span>邮箱</label>
<div class="txt">
<input class="ef" type="text" autocomplete="off" id="email" name="email" maxlength="16" placeholder="请输入合法邮箱,必须包含@" value="123456@">
</div>
</div>
<div class="lr_e">
<label><span class="err" style="display: none" id="fav_err"></span>兴趣爱好</label>
<div class="txt">
<input class="ef" type="checkbox" autocomplete="off" id="" name="fav[]" maxlength="16" value="php">php <input class="ef" type="checkbox" autocomplete="off" id="" name="fav[]" maxlength="16" value="python">python
</div>
</div>
<div class="lr_e">
<label><span class="err" style="display: none" id="verify_err"></span>验证码</label>
<div class="txt">
<input class="ef" type="text" autocomplete="off" id="verify" name="verify" maxlength="16" value=""><?php echo $code;?>
<input class="ef" type="hidden" autocomplete="off" id="verify1" name="verify1" maxlength="16" value="<?php echo strip_tags($code);?>">
</div>
</div>
<div class="btnbox">
<button type="submit" class="p_but" id="submitbtn">注 册</button>
</div>
</form>
</body>
</html>
<?php
header('content-type:text/html;charset=utf-8');
$username=$_POST['username'];
$password=$_POST['password'];
$password1=$_POST['password1'];
$email=$_POST['email'];
$verify=trim(strtolower($_POST['verify']));
$verify1=trim(strtolower($_POST['verify1']));
$fav=$_POST['fav'];
if(!empty($fav)){
$favStr=join(',',$fav);
}
$char=$username{0};
$ascii=ord($char);
$redirectUrl='<br/><a href="reister.php">重写注册</a>';
if(!(($ascii>=65&&$ascii<=90)||($ascii>=97&&$ascii<=122))){
exit('用户名首字母不是以字母开始'.$redirectUrl);
}
$userlen=strlen($username);
if ($userlen<6||$userlen>10) {
exit('用户名长度不符合规范'.$redirectUrl);
}
$passworlen=strlen($password);
if ($passworlen<6||$passworlen>10) {
exit('密码长度不符合规范'.$redirectUrl);
}
if($password!==$password1){
exit('两次密码不一致'.$redirectUrl);
}
if(strpos($email,'@')==false){
exit('非法邮箱'.$redirectUrl);
}
if($verify!==$verify1){
exit('验证码不正确'.$redirectUrl);
}
echo '恭喜你注册成功<br/>';
$password=md5($password);
$userInfo=<<<EOF
<table border='1' width="70%">
<tr>
<td>用户名</td>
<td>密码</td>
<td>邮箱</td>
<td>兴趣爱好</td>
</tr>
<tr>
<td>$username</td>
<td>$password</td>
<td>$email</td>
<td>$favStr</td>
</tr>
</table>
EOF;
echo $userInfo;
数组名称必须带[]
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦