php实现注册审核功能

本章主要实现注册之后审核通过的功能,共这几部分组成:

1. 创建数据库:mydb数据库的user表   注:isok判断是否通过审核,1为通过,0为未通过。

  显示效果:

2.首先做注册界面:zhuce.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>
<form action="zhucecl.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="password" 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="button" value="注册" />



</form>
</body>
</html>

效果展示:

3.针对注册页面做php处理:zhucecl.php

<?php
//把值全取出来
$uid = $_POST["uid"];
$pwd = $_POST["pwd"];
$name = $_POST["name"];
$sex = $_POST["sex"];
$birthday = $_POST["birthday"];

include("fengzhuang/DBDA.class.php");
$db = new DBDA();
//把值添加到数据库形成一条数据
$sql ="insert into user values ('{$uid}','{$pwd}','{$name}',{$sex},'{$birthday}',0)";
//判断这条数据是否为空
if($db->Query($sql,0))
{
    header("location:login.php");
}
else
{
    echo"注册失败!";    
}

?>

引用DBDA.class.php

<?php
class DBDA
{   //设定登录默认值
    public $host = "localhost";
    public $uid = "root";
    public $pwd = "root";
    public $dbname = "mydb";
    //设定$type = 1为查询语句,$type =0为增删改语句
    public function Query($sql,$type=1)
    {     
        $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
        $result = $db->query($sql);
        
        if($type=="1")
        {    //返回查询结果
            return $result->fetch_all();
        }else
        {   //返回ture或false
            return $result;
        }
    }
}

 

4.再做登录页面:

 

<!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="logincl.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="text" name="pwd" /></div>
<input type="submit" value="登录" />
</form>
</body>
</html>

5.在做登录页面的php处理:logincl.php

 

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

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

$sql = "select * from user where uid = '{$uid}'";
$arr = $db->Query($sql);

if($arr[0][1] == $pwd &&!empty($pwd)) 
{
    if($arr[0][5])
    {
        header("location:main.php");
    }
    else
    {
        echo"该用户尚未通过审核!";
    }
}
else
{
    echo"登录失败!";
}

?>

 然后在创建主显示界面:main.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>
        <td>操作</td>
    </tr>
    
    <?php
    include("fengzhuang/DBDA.class.php");
    $db = new DBDA();
    
    $sql = "select * from user";
    $arr = $db->Query($sql);
    
    foreach($arr as $v)
    {
        $str = $v[5]?"<span style='background-color:green'>已通过</span>":"<a href='tongguo.php?uid={$v[0]}'>通过</a>";
        
        echo "<tr>
        <td>{$v[0]}</td>
        <td>{$v[2]}</td>
        <td>{$v[3]}</td>
        <td>{$v[4]}</td>
        <td>{$str}</td>
    </tr>";
    }
    
    ?>

</table>

</body>
</html>

 

posted @ 2017-02-28 15:05  终极用户  阅读(3678)  评论(0编辑  收藏  举报