要求:
注册审核功能,新注册的用户不能登录系统,必须等到管理员审核通过,该用户可以登录系统
注册页面
登录页面--审
审核页面--显示表格,操作里面(如果用户未审核 显示一个审核的超链接或按钮;如果用户已通过审核,显示已通过绿色文字)
解法:
注册页面:
<div> <form action="../chuli/zcchuli.php" method="post"> <div>用户名:<input type="text" name="uid"></div> <div>密码: <input type="text" name="pwd"></div> <div>姓名: <input type="text" name="name"></div> <div>性别: <input type="text" name="sex"></div> <div>生日: <input type="text" name="birthday"></div> <input type="submit" value="注册"/> </form> </div>
<?php include ("../config/DBDA.php"); $uid=$_POST["uid"]; $pwd=$_POST["pwd"]; $sex=$_POST["sex"]=="男"?1:0; var_dump($sex); $birthday=$_POST["birthday"]; $name=$_POST["name"]; $dx=new DBDA(); $sql="insert into users values('{$uid}','{$pwd}','{$name}',{$sex},'{$birthday}',null,'')"; $result=$dx->Query($sql,0); if($result) { header("location:log.php"); } else { echo "注册失败"; }
登录页面:
<div> <form action="../chuli/logchuli.php" method="post"> 用户名:<input type="text" name="uid" /> <br /> 密码: <input type="text" name="pwd"/> <br /> <input type="submit" value="登录"/> </form> </div>
<?php session_start(); include ("../config/DBDA.php"); $uid=$_POST["uid"]; $pwd=$_POST["pwd"]; $dx=new DBDA(); $sql="select pwd from users where uid='{$uid}'"; $pp=$dx->StrQuery($sql); $sql="select isok from users where uid='{$uid}'"; $isok=$dx->StrQuery($sql); if($pp=="") { echo "用户名不存在"; } else { if($pp==$pwd && $isok==1) { $_SESSION["uid"]=$uid; header("location:../module/shenhe.php"); } else { echo "密码错误或审核未通过"; } }
审核页面:
<div> <table align="center" width="100%" height="auto" border="1" cellpadding="0" cellspacing="0"> <tr> <th>用户名</th> <th>密码</th> <th>姓名</th> <th>性别</th> <th>生日</th> <th>操作</th> </tr> <?php session_start(); include ("../config/DBDA.php"); Huihua::dl(); $dx=new DBDA(); $sql="select * from users"; $atr=$dx->Query($sql); foreach($atr as $v) { $sex=$v[3]==1?"男":"女"; $isok=$v[5]==1?"已通过":"<a href='../chuli/shchuli.php?uid={$v[0]}'>审核</a>";//难点 echo "<tr><td align='center'>{$v[0]}</td> <td align='center'>{$v[1]}</td> <td align='center'>{$v[2]}</td> <td align='center'>{$sex}</td> <td align='center'>{$v[4]}</td> <td align='center'>{$isok}</td> </tr>"; } ?> </table> </div>
<?php $uid=$_GET["uid"]; include "../config/DBDA.php"; $dx=new DBDA(); $sql="update users set isok=1 where uid='{$uid}'"; $r=$dx->Query($sql,0); if($r) { header("location:../module/shenhe.php"); }
审核页面: