php......注册审核
Posted 魅影星魂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php......注册审核相关的知识,希望对你有一定的参考价值。
我们在注册之后是不能直接登录的,只有管理员审核通过之后才可以登录,当然,管理员也可以撤销审核。审核多用于办公系统当中。
注册页面:
<h1>注册</h1> <form action="zcchuli.php" method="post"> <div>用户名:<input type="text" name="uid" /></div><br /> <div>密码: <input type="password" 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 /> <div><input type="submit" value="注册" /> </form>
注册处理页面:
<?php $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; $name = $_POST["name"]; $sex = $_POST["sex"]; $birthday = $_POST["birthday"]; //处理性别 $sex = $sex=="男"?true:false; //处理时间,将时间格式化 $time = date("Y-m-d H:i:s"); include("../DB.class.php"); $db = new DB(); $sql = "insert into Users values(\'{$uid}\',\'{$pwd}\',\'{$name}\',{$sex},\'{$birthday}\',\'{$time}\',false)"; echo $sql; if($db->Query($sql,1)) { header("location:zhuce.php"); } else { echo "注册失败!"; }
登录页面:
<h1>登录</h1> <form action="loginchuli.php" method="post"> <div>用户名:<input type="text" name="uid" /></div><br /> <div>密码: <input type="password" name="pwd" /></div><br /> <div><input type="submit" value="登录" /></div> </form>
登录处理页面:
<?php session_start(); $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; include("../DB.class.php"); $db = new DB(); $sql = "select count(*) from Users where Uid = \'{$uid}\' and Pwd = \'{$pwd}\' and IsOk = true";//用户名、密码和审核状态都对,才能登录 $r = $db->StrQuery($sql); if($r==1) { $_SESSION["uid"] = $uid;//将用户名存入session header("location:main.php"); } else { header("location:login.php"); }
主页面(审核页面):
<?php session_start(); if(empty($_SESSION["uid"])) { header("location:login.php"); } $uid = $_SESSION["uid"]; ?> <h1>审核</h1> <table width="800" border="1" cellpadding="0" cellspacing="0"> <tr> <td>姓名</td> <td>性别</td> <td>生日</td> <td>注册时间</td> <td>审核状态</td> </tr> <?php include("../DB.class.php"); $db = new DB(); $sql = "select * from users order by Time desc";//按注册时间降序排序,这样新注册的就会在最上面 $attr = $db->Query($sql); foreach($attr as $v) { //处理状态 $zt = ""; if($v[6]) { $zt = "<span style=\'background-color:green; color:white\'>已通过</span> <a href=\'chexiao.php?uid={$v[0]}\' >撤销</a>"; } else { $zt = "<a href=\'shenhe.php?uid={$v[0]}\'>审核</a>"; //GET传值 } echo "<tr><td>{$v[2]}</td> <td>{$v[3]}</td> <td>{$v[4]}</td> <td>{$v[5]}</td> <td>{$zt}</td></tr>"; } ?> </table>
审核处理页面:
<?php $uid= $_GET["uid"]; include("../DB.class.php"); $db = new DB(); $sql = "update users set IsOk = true where Uid= \'{$uid}\'"; if($db->Query($sql,1)) { header("location:main.php"); } else { echo "审核失败!"; }
撤销页面:
<?php $uid= $_GET["uid"]; include("../DB.class.php"); $db = new DB(); $sql = "update users set IsOk = false where Uid= \'{$uid}\'"; if($db->Query($sql,1)) { header("location:main.php"); } else { echo "撤销失败!"; }
以上是关于php......注册审核的主要内容,如果未能解决你的问题,请参考以下文章