<?php
ob_start();
include('header.html');
print '<body>';
?>
<p style="color:yellow;"><h1> 欢迎来到登录界面!</h1></p>
<p><a href="1.php">退出</a></p>
<p><a href="2.php">注销</a></p>
</body>
</html>
1.php:
<?php
ob_start();
include('header.html');
print '<body>';
?>
<?php
$a=setcookie('zhanghao','');
$a1=setcookie('mima','');
if($a&&$a1)
print '退出成功!';
else print '退出失败!';
?>
</body>
</html>
2.php:
<?php
ob_start();
include('header.html');
print '<body>';
?>
<?php
error_reporting(0);
$_mysqli= new mysqli();
$_mysqli->connect('localhost','root','galgaddott');
$dbc=$_mysqli->select_db('shujuku1');
if($dbc)
{
$query="SELECT * FROM denglu1";
$result=mysqli_query($_mysqli,$query);
if(mysqli_connect_errno($result))
{ print '注销失败1!'; }
else {
while($row=mysqli_fetch_array($result))//匹配
{
if (($_COOKIE['zhanghao']==$row['zhanghao'])&& ($_COOKIE['mima']==$row['mima']))
{
setcookie('zhanghao','');
setcookie('mima','');
$query2="DELETE FROM denglu1 WHERE zhanghao={$row['zhanghao']} LIMIT 1";
mysqli_query($_mysqli,$query2);
print '注销成功!';
header('refresh:3; url=login1.php');
$_mysqli->close();
exit;
}
}
print '注销失败2!';
}
}
else print '注销失败3!';
$_mysqli->close();
?>
</body>
</html>