zoukankan      html  css  js  c++  java
  • 数据访问之注册审核(重点是审核!!!)常用于企业、公司、医院等网站---2017-05-04

    关于审核,如发表文章的审核、员工请假的审核、药品申请的审核等等,代码大同小异。下面来看一下代码是怎么写的:

    用到的数据库:hw_0408  

    用到的表:users

     首先,实现注册功能(zhece.php   chuli.php);  -----往数据库填数据

    1、zhece.php页面:

    页面效果图:

    代码如下:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <form method="post" action="chuli.php">
        <div style="margin:10px 500px"> 
                <h2 > &nbsp;&nbsp; &nbsp; &nbsp;  注册页面</h2>
            <div>用户名:<input type="text" name="users"/></div><br />
            <div>密码:<input type="text" name="pwd"/></div><br />
            <div>姓名:<input type="text" name="name"/></div><br />
            <div>性别:<input type="text" name="sex"/></div><br />
            <div>生日:<input type="text" name="birthday"/></div><br />
            <input type="submit" value="注册" />
            <a href="denglu.php">已有账号,立即登录</a>
            </div>
        </form>
        <body>
        </body>
    </html>

    2、chuli.php页面代码

    <?php
    
    $users = $_POST["users"];
    $pwd = $_POST["pwd"];
    $name= $_POST["name"];
    $sex = $_POST["sex"];
    $birthday = $_POST["birthday"];
    require "DB.class.php";
    $db = new DB();
    $sql = "insert into users values ('','{$users}','{$pwd}','{$name}',{$sex},'{$birthday}',0)";
    if($db->query($sql,0)){
    header("location:zhuce.php");    
        
    }
    ?>

    其次,实现登录功能(denglu.php  login.php )-----判断输入内容是否与数据库相符

    1、denglu.php页面

    效果图:

    代码如下:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
            <form method="post" action="login.php">
        <div style="margin:100px 500px"> 
                <h2 > &nbsp;&nbsp; &nbsp; &nbsp; 登录页面</h2>
            <div>用户名:<input type="text" name="users"/></div><br />
            <div>密码:<input type="text" name="pwd"/></div><br />
            <input type="submit" value="登录" />
            <a href="zhuce.php">没有账号,立即注册</a>
            </div>
        </form>
        </body>
    </html>

    2、login.php页面

    <?php
    
    $users = $_POST["users"];
    $pwd = $_POST["pwd"];
    require "DB.class.php";
    $db = new DB();
    $sql = "select * from users where users = '{$users}'";
    $arr = $db->query($sql);
    
    //$arr[0] [1] 密码
    //$arr [0] [6]  审核   一定要看好索引值是哪个
    
    
    if($arr[0][2] == $pwd && !empty($pwd))
    {
        if($arr[0][6])
        {
            echo "登录成功!";
        }
        else{
            echo "审核未通过!";
        }
    }
    else{
        echo "用户名或密码错误!";
    }
    
    ?>

    最后,实现管理员的审核功能(guangliyuan.php  shenhe.php  chexiao.php);重点重点重点!!!

    1、guangliyuan.php

    点击“未审核”,则变成审核通过;点击撤销,则变成未审核状态

    效果图:

    代码如下:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
        <body>
            
            <table width="100%" border="1px" cellpadding="0px" cellspacing="0px">
                <tr>
                    <td>用户名</td>
                    <td>密码</td>
                    <td>姓名</td>
                    <td>性别</td>
                    <td>生日</td>
                    <td>审核</td>
                </tr>
                <?php
                    require "DB.class.php";
                    $db = new DB();
                    $sql = "select * from users";
                    $arr = $db->query($sql);
                    foreach($arr as $v)
                    {
                        
                        //实现审核功能
                        $str ="";
                        if($v[6])
                        {
                            $str = "<span style='color:green'> 审核通过 </span>
                            <a href='chexiao.php?users={$v[1]}' style='color:red'>撤销</a>";
                        }
                        else
                        {
                            $str = "<a href='shenhe.php?users={$v[1]}' style='color:red'>未审核</a>";
                        }
                        
                        echo "
                            <tr>
                    <td>{$v[1]}</td>
                    <td>{$v[2]}</td>
                    <td>{$v[3]}</td>
                    <td>{$v[4]}</td>
                    <td>{$v[5]}</td>
                    <td>{$str}</td>
                </tr>    ";
                    }
                     ?>    
            </table>
            
            
        </body>
    </html>

    2、 shenhe.php

    <?php
    $users = $_GET["users"];
    //var_dump($users);
    require "DB.class.php";
    $db = new DB();
    $sql = "update users set isok = 1 where users='{$users}' ";
    $db->query($sql,0);
    header("location:guanliyuan.php");
    
    ?>

    3、 chexiao.php

    <?php
    $users = $_GET["users"];
    //var_dump($users);
    require "DB.class.php";
    $db = new DB();
    $sql = "update users set isok = 0 where users='{$users}' ";
    $db->query($sql,0);
    header("location:guanliyuan.php");
    
    ?>
  • 相关阅读:
    【原创】Apache ab结果参数详解
    【转载】QPS,用户平均等待时间,服务器平均请求处理时间
    【原创】Apache ab测试时出现:apr_socket_recv "connection reset by peer" 104
    【做题】Codeforces Round #429 (Div. 2) E. On the Bench——组合问题+dp
    oracle递归查询
    http1.0和1.1的区别
    here with you
    spring杂碎
    西海情歌
    //随机生成 10到20条数据 数据包含 用户名(5-10位的字母) 性别 年龄(1-100岁)
  • 原文地址:https://www.cnblogs.com/chenguanai/p/6808011.html
Copyright © 2011-2022 走看看