PHP 注册审核
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>密码: <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>密码: <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 /> <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"注册失败"; }
shenhe.php
<style type="text/css"> .biao { padding-left:550px; padding-top:30px; } .div { padding-left:200px; padding-top:20px; } </style> </head> <?php session_start(); include("../dbda.php"); $db=new DBDA(); //用empty方法判断一下是否为空,防止用户绕过登录直接访问 if(empty($_SESSION["uid"])) { header("location:login.php"); exit; } ?> <body> <div class="biao"> <h1>审核页面</h1> </div> <div class="div"> <table width="80%" border="1" cellpadding="0" cellspacing="0"> <tr height="35px" align="center" style="font-weight:bold"> <td>用户名</td> <td>姓名</td> <td>性别</td> <td>生日</td> <td>操作</td> </tr> <?php $sql="select * from users"; $attr=$db->Query($sql); foreach($attr as $v) { //处理性别 $sex=$v[3]?"男":"女"; //处理操作 $caozuo=$v[5]?"<span style='background-color:green'>已通过</span>":"<a href='shenhechuli.php?uid={$v[0]}'>审核</a>"; echo" <tr height='30px' align='center'> <td>{$v[0]}</td> <td>{$v[2]}</td> <td>{$sex}</td> <td>{$v[4]}</td> <td>{$caozuo}</td> </tr>"; } ?> </table> </div>
shenhechuli.php
<?php include("../dbda.php"); $db=new DBDA(); $uid=$_GET["uid"]; $sql="update users set isok=true where uid='{$uid}'"; $db->Query($sql,1); header("location:shenhe.php");