zoukankan      html  css  js  c++  java
  • 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>
  • 相关阅读:
    springMVC,spring,mybatis全注解搭建框架--第一步,让框架跑起来
    实现excel导入导出功能,excel导入数据到页面中,页面数据导出生成excel文件
    不带插件 ,自己写js,实现批量上传文件及进度显示
    excel转html 实现在线预览
    word和.txt文件转html 及pdf文件, 使用poi jsoup itext心得
    实现图片旋转,滚动鼠标中间对图片放大缩小
    面试中常见问题之线程池与连接池的区别
    实例测试mysqlRR模式和RC模式各种锁情况
    分糖果
    MySQL试题
  • 原文地址:https://www.cnblogs.com/shenzikun1314/p/6478950.html
Copyright © 2011-2022 走看看