1. 程式人生 > >php數據訪問-註冊審核(重點)

php數據訪問-註冊審核(重點)

require upd input 100% div header pda font bmi

關於審核,如發表文章的審核、員工請假的審核、藥品申請的審核等等,代碼大同小異。

一.註冊功能(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 > &nbsp;&nbsp; &nbsp; &nbsp; 註冊頁面</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 > &nbsp;&nbsp; &nbsp; &nbsp; 登錄頁面</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數據訪問-註冊審核(重點)