php 之 注册审核(0523)

时间:2023-03-09 21:02:32
php 之 注册审核(0523)

当注册后,先将信息保存到session,通过审核后才会添加到数据库中,

审核通过后状态变为已通过,这时添加到数据库中的信息进行登录。若发现此用户的不良行为,可以撤销通过。

注册页面:

 <!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>
<form action="zcchuli.php" method="post">
<div>
用户名:<input type="text" name="uid" /><br /><br />
密 码:<input type="text" name="psw" /><br /><br />
姓 名:<input type="text" name="name" /><br /><br />
性 别:<input type="text" name="sex" /><br /><br />
生 日:<input type="text" name="birthday" /><br /><br />
<input type="submit" value="注册" />
</div>
</form> </body>
</html>

注册处理:(注册成功后要进行审核)

 <?php
include ("../DBDA.class.php");
$db=new DBDA();
$uid=$_POST["uid"];
$psw=$_POST["psw"];
$name=$_POST["name"];
$sex=$_POST["sex"]; $s=1;
if($sex=="女")
{
$s=0;
} $birthday=$_POST["birthday"]; $sql = "insert into Users values('{$uid}','{$psw}','{$name}',{$s},'{$birthday}',false)"; //echo $sql;
$r=$db->Query($sql,1); if($r)
{
header ("location:zhuce.php");
}
else
{
echo "注册失败!";
}

登录页面:

 <!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>
<form action="dlchuli.php" method="post">
<div>
用户名:<input type="text" name="uid" /><br /><br /> 密&nbsp;&nbsp;码:<input type="text" name="psw" /><br /><br /> <input type="submit" value="登录" />
</div>
</form> </body>
</html>

登录处理:(审核通过才能登录)

 <?php
session_start();
include ("../DBDA.class.php");
$db=new DBDA(); $uid=$_POST["uid"];
$psw=$_POST["psw"]; $sql="select count(*) from users where uid='{$uid}' and psw='{$psw}' and isok=true"; $r=$db->StrQuery($sql); if($r==1)
{
$_SESSION["uid"]=$uid;
header("location:main.php");
}
else
{
header("location:denglu.php");
}

审核主页面:(只管理员可见)

 <!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>
<td>状态</td>
</tr> <?php
include ("../DBDA.class.php");
$db=new DBDA();
$sql="select * from users";
$attr=$db->Query($sql);
foreach($attr as $v)
{ //状态判断isok
$zt="";
if($v[5])
{
$zt="<span style='color:green'>已通过</span>&nbsp;<a href='chexiao.php?uid={$v[0]}'>撤销</a>";
}
else
{
$zt="<a href='shchuli.php?uid={$v[0]}'>审核</a>";
} echo "<tr>
<td>{$v[2]}</td>
<td>{$v[3]}</td>
<td>{$v[4]}</td>
<td>{$zt}</td>
</tr>"; } ?>
</table>
</body>
</html>

审核处理:(审核成功显示已通过)

 <?php
$uid=$_GET["uid"]; include("../DBDA.class.php");
$db=new DBDA(); $sql="update users set isok=true where uid='{$uid}'"; if($db->Query($sql,1))
{
header("location:main.php");
}
else
{
echo "审核失败!";
}

撤销处理:(撤销审核,无法登录)

 <?php
$uid=$_GET["uid"];
include ("../DBDA.class.php");
$db=new DBDA();
$sql="update users set isok=false where uid='{$uid}'";
if($db->Query($sql,1))
{
header("location:main.php");
}
else
{
echo "撤销失败!";
}

页面运行显示:

php 之 注册审核(0523)

php 之 注册审核(0523)

php 之 注册审核(0523)