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>
</head>

<body>
<h1>注册</h1>
<form action="zcchuli.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="text" name="pwd" /></div>
<div>姓名:<input type="text" name="name" /></div>
<div>性别:<input type="text" name="sex" /></div>
<div>生日:<input type="text" name="birthday" /></div>
<div><input type="submit" value="注册" /></div>
</form>
</body>
</html>

<?php
$uid = $_POST["uid"];
$pwd = $_POST["pwd"];
$name = $_POST["name"];
$sex = $_POST["sex"];
$birthday = $_POST["birthday"];


$sex = $sex == "男"?true:false;

include("../DBDA.php");
$db = new DBDA();

$sql = "insert into Users values('{$uid}','{$pwd}','{$name}',{$sex},'{$birthday}',false)";

if($db->Query($sql,0))
{
header("location:zhuce.php");
}

<?php

$uid = $_GET["uid"];

include("../DBDA.php");
$db = new DBDA();

$sql = "update Users set Isok=true where Uid='{$uid}'";

if($db->Query($sql,0))
{
header("location:main.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>
<h1>审核</h1>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>姓名</td>
<td>性别</td>
<td>生日</td>
<td>状态</td>
</tr>
<?php

include("../DBDA.php");
$db = new DBDA();

$sql = "select * from Users";

$attr = $db->Query($sql);

foreach($attr as $v)
{
//处理状态
$zt = "";
if($v[5])
{
$zt = "<span style='background-color:green;color:white'>已通过</span><a href='chexiao.php?uid={$v[0]}'>撤销</a>";
}
else
{
$zt = "<a href='shenhe.php?uid={$v[0]}'>审核</a>";
}

echo "<tr>
<td>{$v[2]}</td>
<td>{$v[3]}</td>
<td>{$v[4]}</td>
<td>{$zt}</td>
</tr>";
}

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

<!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>
<h1>登录</h1>
<form action="dlchuli.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="text" name="pwd" /></div>
<div><input type="submit" value="登录"/></div>
</form>
</body>
</html>.

<?php
session_start();

$uid = $_POST["uid"];
$pwd = $_POST["pwd"];

include("../DBDA.php");
$db = new DBDA();

$sql = "select count(*) from Users where Uid = '{$uid}' and Pwd= '{$pwd}' and Isok=true";

$z = $db->StrQuery($sql);

if($z == 1)
{
$_SESSION["uid"]=$uid;
header("location:main.php");
}
else
{
header("location:login.php");
}

<?php
$uid = $_GET["uid"];

include("../DBDA.php");
$db = new DBDA();

$sql = "update Users set Isok=false where Uid='{$uid}'";

if($db->Query($sql,0))
{
header("location:main.php");
}
else
{
echo "撤销失败!";
}

原文地址:https://www.cnblogs.com/xiongxiaobai/p/5527212.html