php注册审核

今天下午讲了php与mysql连接的注册审核页面设计,我们想要的效果如下:

如果点击最后的通过按钮,显示效果会像上面已通过的效果,自己可以通过改变用户的审核状态让用户可以成功登陆与否。

注册,登陆界面如下:

login.php页面如下:

<style type="text/css">
.biao
{
    padding-left:550px;
    padding-top:30px;
}
.div
{
    padding-left:500px;
    padding-top:20px;
}
.but
{
    padding-left:200px;
}
</style>
</head>

<body>
<div class="biao">
    <h1>登录页面</h1>
</div>
<div class="div">
<form action="loginchuli.php" method="post">
    <div>用户名:<input type="text" name="uid"/></div><br />
    <div>密码:&nbsp;&nbsp;<input type="password" name="pwd" /></div><br />
    <div class="but">
        <input type="submit" value="登录" />
    </div>
</form>
</div>

loginchuli.php页面

<?php
session_start();
include("../dbda.php");
$db=new DBDA();

$uid=$_POST["uid"];
$pwd=$_POST["pwd"];

//根据用户名查密码
$sql="select pwd from users where uid='{$uid}'";
$mima=$db->strquery($sql);//用strquery直接返回密码

$sqlzt="select isok from users where uid='{$uid}'";
$zt=$db->strquery($sqlzt);

//判断用户的输入是否为空
if($uid!=""&&$pwd!="")
{
    //判断输入是否正确
    if($pwd==$mima)
    {
        if($zt==1)
        {
        //把用户名存到session里面
        $_SESSION["uid"]=$uid;
        header("location:shenhe.php");
        }
        else
        {
            echo"还未审核通过";    
        }
    }
    else
    {
        echo"用户名或密码输入错误";    
    }
}
else
{
    echo"用户名或密码不能为空";    
}

zhuce.php页面

<style type="text/css">
.biao
{
    padding-left:550px;
    padding-top:30px;
}
.div
{
    padding-left:500px;
    padding-top:20px;
}
.but
{
    padding-left:200px;
}
</style>
</head>

<body>
<div class="biao">
<h1>注册页面</h1>
</div>
<div class="div">
<form action="zhucechuli.php" method="post">
    <div>用户名:<input type="text" name="uid" /></div><br />
    <div>密码:&nbsp;&nbsp;<input type="text" name="pwd" /></div><br />
    <div>姓名:&nbsp;&nbsp;<input type="text" name="name" /></div><br />
    <div>性别:&nbsp;&nbsp;<input type="text" name="sex" /></div><br />
    <div>生日:&nbsp;&nbsp;<input type="text" name="birthday" /></div><br />
    <div class="but">
           <input type="submit" value="注册" />
    </div>
</form>
</div>

zhucechuli.php页面:

<?php
include("../dbda.php");
$db=new DBDA();

//用POST方法取传过来的值
$uid=$_POST["uid"];
$pwd=$_POST["pwd"];
$name=$_POST["name"];
$sex=$_POST["sex"]=="男"?1:0;
$birthday=$_POST["birthday"];

//写sql语句把值存到表里
$sql="insert into users values('{$uid}','{$pwd}','{$name}',$sex,'{$birthday}',false)";//布尔型值不加单引号
var_dump ($sql,$sex);
if($db->Query($sql,1))
{
    header("location:zhuce.php");
}
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="1px" cellpadding="0" cellspacing="0">
    <tr>
        <td>用户名</td>
        <td>姓名</td>
        <td>性别</td>
        <td>生日</td>
        <td>操作</td>
    </tr>
 <?php
        include("DBDA.class.php");
        $db = new DBDA();
        
        $sql = "select * from users";
        $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>

通过页面(tongguo.php):

<?php
$uid = $_GET["uid"];
include("DBDA.class.php");
$db = new DBDA();

$sql = "update users set isok=1 where uid='{$uid}'";
if($db->Query($sql,0))
{
    header("location:main.php");
}
else
{
    echo "通过失败!";
}
原文地址:https://www.cnblogs.com/axj1993/p/6479521.html