php数据访问-注册审核(重点)
Posted ChrissZhao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php数据访问-注册审核(重点)相关的知识,希望对你有一定的参考价值。
关于审核,如发表文章的审核、员工请假的审核、药品申请的审核等等,代码大同小异。
一.注册功能(zhece.php chuli.php)
1.zhece.php
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <form method="post" action="chuli.php"> 8 <div style="margin:10px 500px"> 9 <h2 > 注册页面</h2> 10 <div>用户名:<input type="text" name="users"/></div><br /> 11 <div>密码:<input type="text" name="pwd"/></div><br /> 12 <div>姓名:<input type="text" name="name"/></div><br /> 13 <div>性别:<input type="text" name="sex"/></div><br /> 14 <div>生日:<input type="text" name="birthday"/></div><br /> 15 <input type="submit" value="注册" /> 16 <a href="denglu.php">已有账号,立即登录</a> 17 </div> 18 </form> 19 <body> 20 </body> 21 </html>
2.chuli.php
1 <?php 2 3 $users = $_POST["users"]; 4 $pwd = $_POST["pwd"]; 5 $name= $_POST["name"]; 6 $sex = $_POST["sex"]; 7 $birthday = $_POST["birthday"]; 8 require "DBDA.class.php"; 9 $db = new DBDA(); 10 $sql = "insert into users values (\'{$users}\',\'{$pwd}\',\'{$name}\',{$sex},\'{$birthday}\',0)"; 11 if($db->query($sql,0)){ 12 header("location:zhuce.php"); 13 14 } 15 ?>
二.登录功能(denglu.php login.php )
1.denglu.php
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <body> 8 <form method="post" action="login.php"> 9 <div style="margin:100px 500px"> 10 <h2 > 登录页面</h2> 11 <div>用户名:<input type="text" name="users"/></div><br /> 12 <div>密码:<input type="text" name="pwd"/></div><br /> 13 <input type="submit" value="登录" /> 14 <a href="zhuce.php">没有账号,立即注册</a> 15 </div> 16 </form> 17 </body> 18 </html>
2.login.php
1 <?php 2 3 $users = $_POST["users"]; 4 $pwd = $_POST["pwd"]; 5 require "DBDA.class1.php"; 6 $db = new DBDA(); 7 $sql = "select * from users where users = \'{$users}\'"; 8 $arr = $db->query($sql); 9 10 //$arr[0][1] 密码 11 //$arr[0][5] 审核状态 12 13 14 if($arr[0][1] == $pwd && !empty($pwd)) 15 { 16 if($arr[0][5]) 17 { 18 echo "登录成功!"; 19 } 20 else{ 21 echo "审核未通过!"; 22 } 23 } 24 else{ 25 echo "用户名或密码错误!"; 26 } 27 28 ?>
三.管理员的审核功能(guanliyuan.php tongguo.php chexiao.php)
1.guanliyuan.php
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 8 <body> 9 <h1>管理员审核</h1> 10 <table width="100%" border="1" cellpadding="0" cellspacing="0"> 11 <tr> 12 <td>用户名</td> 13 <td>密码</td> 14 <td>姓名</td> 15 <td>性别</td> 16 <td>生日</td> 17 <td>操作</td> 18 </tr> 19 <?php 20 require"DBDA.class1.php"; 21 $db = new DBDA(); 22 23 $sql = "select * from users"; 24 $arr = $db->query($sql); 25 26 foreach($arr as $v) 27 { 28 $str = ""; 29 if($v[5]) 30 { 31 $str = "<span style=\'color:green\'>已通过</span> 32 <a href=\'chexiao.php?uid={$v[0]}\'>撤销</a>"; 33 } 34 else 35 { 36 $str = "<a href=\'tongguo.php?uid={$v[0]}\'>通过</a>"; 37 } 38 39 echo "<tr> 40 <td>{$v[0]}</td> 41 <td>{$v[1]}</td> 42 <td>{$v[2]}</td> 43 <td>{$v[3]}</td> 44 <td>{$v[4]}</td> 45 <td>{$str}</td> 46 </tr>"; 47 } 48 ?> 49 </table> 50 </body> 51 </html>
2.tongguo.php
1 <?php 2 $uid = $_GET["uid"]; 3 require "DBDA.class.php"; 4 $db = new DBDA(); 5 $sql = "update users set isok=1 where uid=\'{$uid}\'"; 6 $db->query($sql,0); 7 header("location:guanliyuan.php");
3.chexiao.php
1 <?php 2 $uid = $_GET["uid"]; 3 require "DBDA.class.php"; 4 $db = new DBDA(); 5 $sql = "update users set isok=0 where uid=\'{$uid}\'"; 6 $db->query($sql,0); 7 header("location:guanliyuan.php");
以上是关于php数据访问-注册审核(重点)的主要内容,如果未能解决你的问题,请参考以下文章