注册审核(审核状态控制登录、可以更改审核状态)
1.创建登录界面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <form action="loginchuli.php" method="post"> <div>用户名:<input type="text" name="uid" /></div> <div>密码:<input type="text" name="pwd" /></div> <div><input type="submit" value="登录" /></div> </form> </body> </html>
2.登录处理页面,数据库中有登录信息并且该信息的审核状态为1才可以登录。
<?php $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; include("../DBDA.class.php");//DBDA.class.php在上一级目录 $db = new DBDA(); $sql = "select pwd from users where uid='{$uid}'"; $mm = $db->StrQuery($sql); if($pwd != "" && $pwd==$mm) { $ssh = "select isok from users where uid='{$uid}'"; $n = $db->StrQuery($ssh); if($n==1)//如果审核状态是1,就跳转页面。 { header("location:main.php"); } else { echo "该账号还未经过审核"; } } else { echo "用户名或密码错误"; }
3.创建主页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <h1>注册审核</h1> <table width="100%" border="1" cellpadding="0" cellspacing="0"> <tr> <td>用户名</td> <td>姓名</td> <td>状态</td> </tr>
<?php include("../DBDA.class.php"); $db = new DBDA(); $sql = "select * from users"; $attr = $db->Query($sql); foreach($attr as $v) { //处理状态 $zt = ""; if($v[5]==1) { $zt = "<span style='color:green'>已通过</span>"; } else { $zt = "<a href='shenhe.php?u={$v[0]}'>审核</a>"; } echo "<tr><td>{$v[0]}</td><td>{$v[2]}</td><td>{$zt}</td></tr>"; } ?>
</table> </body> </html>
4.审核页面,可以把未审核的数据通过点击“审核”按钮改变。
<?php include("../DBDA.class.php"); $db = new DBDA(); $uid = $_GET["u"]; $sql = "update users set isok=1 where uid='{$uid}'";//把审核状态的值改为1 $db->Query($sql,0); header("location:main.php");