php注册审核例子

首先是注册

<form action="dlchuli.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="text" name="pwd" /></div>
<div>姓名:<input type="text" name="uname" /></div>
<div>性别:<input type="radio" name="sex" id="nan" value="1">男</label>
		<label class="btn btn-primary"><input type="radio" name="sex" id="nv" value="0">女</label>
</div>
<div>生日:<input type="text" name="birthday" /></div>
<div>工号:<input type="text" name="gcode"></div>
<input type="submit" value="注册" />
</form>

  dlchuli.php页面

<?php
    $uid = $_POST["uid"];
	$pwd = $_POST["pwd"];
	$uname = $_POST["uname"];
	$sex = $_POST["sex"];
	$birthday = $_POST["birthday"];
	$gcode = $_POST["gcode"];
	require_once "./lib/DBDA.class.php";
	$db = new DBDA();
	$sql = "insert into user values('{$uid}','{$pwd}','{$uname}','{$sex}','{$birthday}','{$gcode}',0)";
	$result = $db->query($sql,1);
	if($result){
		echo "注册成功";
		}else{
			echo "注册失败";
			}

 接下来登录

 

<body>
<form action="./denglucl.php" method="post">
用户名:<input type="text" name="uid" />
密码:<input type="text" name="pwd" />
<input type="submit" value="登录"/>
</form>
</body>

  登录处理页面

<?php
$uid = $_POST["uid"];
$pwd = $_POST["pwd"];
require_once "./lib/DBDA.class.php";
$db = new DBDA();
$sql = "select * from user where uid = '{$uid}'";//
$arr = $db->query($sql);
if($arr[0][1] == $pwd && !empty($pwd)){
	if($arr[0][6]){//判断验证密码时加上isok这一栏是1?是就通过,不是就提示“未通过审核”
		header("location:shenhe.php");
	}else{
		echo "该用户尚未通过审核!";
	}
}else{
	echo "登录失败!";
}

  如果没通过审核,通过审核页面进入,点击通过

<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
	<td>用户名</td>
    <td>姓名</td>
    <td>性别</td>
    <td>生日</td>
    <td>操作</td>
</tr>
<?php 
	require_once "./lib/DBDA.class.php";
	$db = new DBDA();
	$sql = "select * from user";
	$arr = $db->query($sql);
	foreach($arr as $v){
		$str = $v[6]?"<span style='background-color:green'>已通过</span>":"<a href='tongguo.php?uid={$v[0]}'>通过</a>";
		echo "<tr><td>{$v[0]}</td>
    			<td>{$v[2]}</td>
    			<td>{$v[3]}</td>
   				<td>{$v[4]}</td>
    			<td>{$str}</td></tr>";	
	}
?>

  

<a href='tongguo.php?uid={$v[0]}'>通过</a>这里通过get方式将主键值传到处理页面
<?php
$uid = $_GET["uid"];
require_once "./lib/DBDA.class.php";
$db = new DBDA();
$sql = "update user set isok=1 where uid='{$uid}'";
$result = $db->query($sql,1);
header("location:shenhe.php");

 返回后再次输入用户名密码就可以登录了 

猜你喜欢

转载自www.cnblogs.com/forqiwen/p/8915577.html
今日推荐