php注册审核

通过注册审核,判断刚创建的账户是否可以使用。

后台管理员审核通过后,账号可以使用。

通过session 设置只能通过登录入口进入网页。

原理:通过数据库设置账号的一个字段状态,例: isok:1, isok:0,当isok为1时审核通过,此账号可以使用,当isok为0时审核未通过,此账号不可使用。

 

 

数据库示例:

 

审核通过后数据库中isok字段值为1,不通过值为0。

 

新建登录与注册界面:

<h1>注册页面</h1>
<form action="zhucechili.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>

  

<form action="loginchuli.php" method="post">
	<div>用户名:<input type="text" name="uid" /></div>
    <div>密码:<input type="password" name="pwd" /></div>
    <input type="submit" value="登录" />
</form>

 

注册界面表单提交至相应路径下的zhucechuli.php文件。

登录表单提交至相应路径下的loginchuli.php文件。 

数据库文件中表名字为 users。

 

 

引入数据库查询的类文件:

DBDA.class.php

<?php
class DBDA
{
	public $host="localhost";
	public $uid = "root";
	public $pwd = "";
	public $dbname = "12345";
	
	//成员方法
	public function Query($sql,$type=1)
	{
		$db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
		$r = $db->query($sql);
		
		if($type==1)
		{
			return $r->fetch_all();
		}
		else
		{
			return $r;
		}
	}
}

  

登录处理界面(loginchuli.php文件):

<?php
$uid = $_POST["uid"];
$pwd = $_POST["pwd"];

include("DBDA.class.php");
$db = new DBDA();

$sql = "select pwd from users where uid='{$uid}'";

$attr = $db->Query($sql);

if(!empty($pwd) && !empty($attr) && $attr[0][0] == $pwd)
{
	//密码正确,判断状态
	$szt = "select isok from users where uid='{$uid}'";
	$azt = $db->Query($szt);
	if($azt[0][0])                               //数据库中isok字段为布尔型,可以直接判断
	{ 
		echo "可以登录";
	}
	else                         //isok字段为0审批未通过
	{
		echo "未通过审核!";
	}
}
else
{
	//密码错误
	echo "密码不对";
}

  

 

注册处理界面(zhucechuli.php文件):

<?php
$uid = $_POST["uid"];
$pwd = $_POST["pwd"];
$name = $_POST["name"];
$sex = $_POST["sex"];
$birthday = $_POST["birthday"];

include("DBDA.class.php");
$db = new DBDA();

$sql = "insert into users values('{$uid}','{$pwd}','{$name}',{$sex},'{$birthday}',0,'')";

$db->Query($sql,0);

header("location:login.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>
    	<th>用户名</th>
        <th>密码</th>
        <th>姓名</th>
        <th>性别</th>
        <th>生日</th>
        <th>状态</th>
    </tr>
    
    <?php
	include("DBDA.class.php");
	$db = new DBDA();
	
	$sql = "select * from users";
	$attr = $db->Query($sql);
	foreach($attr as $v)
	{
		$zt = $v[5];
		$str = "";
		if($zt)
		{
			$str = "<span style=' color:green'>已通过</span><a href='bohui.php?uid={$v[0]}'>驳回</a>";
		}
		else
		{
			$str = "<a href='tongguo.php?uid={$v[0]}'>通过</a>";
		}
		
		echo "<tr>
    	<td>{$v[0]}</td>
        <td>{$v[1]}</td>
        <td>{$v[2]}</td>
        <td>{$v[3]}</td>
        <td>{$v[4]}</td>
        <td>{$str}</td>
    </tr>";
	}
	
	?>


</table>

</body>
</html>

  

审核通过与审核驳回

<?php

$uid = $_GET["uid"];                     //审核通过

include("DBDA.class.php");
$db = new DBDA();

$sql = "update users set isok=1 where uid='{$uid}'";
$db->Query($sql,0);

header("location:shenhe.php");

  

<?php

$uid = $_GET["uid"];                                       //审核驳回

include("DBDA.class.php");
$db = new DBDA();

$sql = "update users set isok=0 where uid='{$uid}'";
$db->Query($sql,0);

header("location:shenhe.php");

  

当给第一行用户驳回时:

再次出现审核链接。

 

 

当点击通过时:

 

posted @ 2016-12-29 15:07  发瑞  阅读(810)  评论(0编辑  收藏  举报