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>
<style type="text/css">
.a
{
  top:100px;
  height:400px;
  width:60%;
  left:20%;
  position:absolute;
  border:2px solid #F00;
}
.b
{
    margin-top:10px;
    width:80%;
    height:20px;
    left:10%;


}
.btn1
{
    width:60px;
    height:30px;
    margin-right:10px;
    
}
.btn2
{   
    width:60px;
    height:30px;
    margin-left:10px;    
}
</style>
</head>

<body>

<div class="a"><form action="zhucechuli.php" method="post" enctype="multipart/form-data">
<span<h1>注册</h1></span>
<div class="b">用户名<input type="text" id="uid"/></div>
<div class="b">密&nbsp;码<input type="text" name="pwd"/></div>
<div class="b">姓&nbsp;名<input type="text" name="name"/></div>
<div class="b">性&nbsp;别<input type="text" name="sex"/></div>
<div class="b">生&nbsp;日<input type="text" name="birthday"/></div>
<div class="b">头&nbsp;像<input type="file" name="file"/></div>
<div class="b" align="left"><input type="submit" class="btn1" value="注册" /><input type="button"  class="btn2" value="取消"/></div>
</form>
</div>
</body>
</html>

注册处理页面

<?php
include ("../DBDA.class.php");
$db=new DBDA();
//控制上传文件大小和格式
if(($_FILES["file"]["type"]=="image/jpeg"||$_FILES["file"]["type"]=="image/png")&& $_FILES["file"]["size"]<=10000)
{
    //处理文件名
    $filename="./img/".time().$_FILES["file"]["name"];
    //转编码格式
    $filename=iconv("UTF-8","gb2312",$filename);
    //判断文件是否存在
    if(!file_exists($filename))
    { //上传保存
       move_uploaded_file($_FILE["file"]["tmp"],$filename);
    }
}
$uid=$_POST["uid"];
$pwd=$_POST["pwd"];
$name=$_POST["name"];
$sex=$_POST["sex"];
$birthday=$_POST["birthday"];
$isok=1;
$url="/lianxi/zhuceyanzheng/".$filename;
$sql="insert user values('','{$uid}','{$pwd}','{$name}','{$sex}','{$birthday}','{$url}'),'{$isok}'";
$result=$db->Query($sql);
if($result)
{
    header("location:denglu.php");
}
else
{
    echo "注册失败";
}

注册审核页面

<!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>

<table align="center" border="1" > 
<tr>
<td>用户名</td>
<td>密码</td>
<td>姓名</td>
<td>性别</td>
<td>生日</td>
<td>头像</td>
<td>操作</td>
<?php
session_start();
if(empty($_SESSION["uid"]))
{
    header("location:denglu.php");
    exit();
}
include("../DBDA.class.php");
$db=new DBDA();
$sql="select * from user ";
$attr=$db->Query($sql);
foreach ($attr as $v)
{   
    //处理性别
    if($v[4]==1)
    {
        $a="";
    }
    else if ($v[4]==0)
    {
        $a="";
    }
    //处理操作
    $str="";
    if($v[7]==1)
    {
        $str="<a href='shenhechuli.php?id={$v[0]}'>审核</a>";
    }
    else if($v[7]==2)
    {
        $str="<span><font color='#00FFFF'>已通过</font></span> ";
    }
    echo "<tr>
    <td>{$v[1]}</td>
    <td>{$v{2}}</td>
    <td>{$v[3]}</td>
    <td>{$a}</td>
    <td>{$v[5]}</td>
    <td>{$v[6]}</td>
    <td>{$str}</td>
    </tr>";
}

?>
</tr>
</table>
</body>
</html>

审核处理

<?php
$id=$_GET["id"];
include ("../DBDA.class.php");
$db=new DBDA();
$sql="update user set isok='2' where id='{$id}'";
$result=$db->Query($sql,0);
if($result)
{
    header("location:denglushenhe.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>
<style type="text/css">
.a
{
  top:100px;
  height:400px;
  width:60%;
  left:20%;
  position:absolute;
  border:2px solid #F00;
}
.b
{
    margin-top:10px;
    width:80%;
    height:20px;
    left:10%;


}
.btn1
{
    width:60px;
    height:30px;
    margin-right:10px;
    
}
.btn2
{   
    width:60px;
    height:30px;
    margin-left:10px;    
}
</style>
</head>

<body>

<div class="a"><form action="dengluchuli.php" method="post" >
<span<h1>登录</h1></span>
<div class="b">用户名<input type="text" name="uid"/></div>
<div class="b">密&nbsp;码<input type="text" name="pwd"/></div>
<div class="b" align="left"><input type="submit" class="btn1" value="登录" /><input type="button"  class="btn2" value="取消"/></div>
</form>
</div>
</body>
</html>

登录处理

<?php
$uid=$_POST["uid"];
$pwd=$_POST["pwd"];
include ("../DBDA.class.php");
$db=new DBDA();
$sql="select pwd from user where uid='{$uid}'";
$atrr=$db->Query($sql);
$mima=$atrr[0][0];
$sql1="select isok from user where uid='{$uid}'";
$atrr1=$db->Query($sql1);
$isok=$atrr1[0][0];
if($uid!=""&&$pwd!="")
{
    if ($uid==$mima &&($isok==2||$isok==3))
    {
        $_SESSION["uid"]=$uid;
        header("location:index");
    }
    else
    {
        echo "审核未通过或密码错误";
    }
}

 

posted on 2016-07-03 23:06  。。小兵  阅读(187)  评论(0编辑  收藏  举报