After successful login, we enter the main.php page and enter the management page
Let’s take a look at the following top.php page
<?php session_start(); ?> <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8"> <style type="text/css"> body{margin-top:50px;text-align:center;} a{text-decoration:none;float:right;margin-right:15px;color:red;} </style> </head> <body> <h1>合肥领航环保科技公司后台管理系统</h1> <?php if(!empty($_SESSION['username'])){ ?> <a href="loginout.php?act=loginout" target="_top">退出</a> <?php } ?> </body> </html>
We also need to open the session first. After successful login before, we The form information has been stored in the session. Now we will judge the username in the session on this page. If the username in the session has a value
we will display the exit on the top page
Let’s look at the following exit Function code
Exit and submit to loginout.php
Let’s look at the code:
<?php
session_start();
if($ _GET['act'] == 'loginout'){
unset($_SESSION);
echo "<script>location.href='log.php';</script>";
}
?>
In this way we have completed the exit function