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>

 

转载于:https://www.cnblogs.com/shenzikun1314/p/6478950.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值