这是我db.classes登录和注销重定向后PHP
public function login($un, $pw)
{
$result = mysqli_query($this->dbh,"select username, password from users where username='$un' and password='$pw'");
$count=mysqli_num_rows($result);
if($count==1){
header("location:home.php");
}
else {
echo
"<script type='text/javascript'>
alert('LOG-IN FAILED!');
</script>";
echo '<script language="JavaScript"> window.location.href ="index.php" </script>';
}
}
这是我的PHP
<?PHP
include("db.classes.php");
$g = new DB();
$g->connection();
if(isset($_POST['subBtn']))
{
$un = $g->clean($_POST["uname"]);
$pw = $g->clean($_POST["pass"]);
$g->login($un, $pw);
}
$g->close();
?>
这里是我的注销按钮
<div id="footer">
<li id="Login"><a href="index.php">Log Out</a></li>
</div>
我怎样才能防止用户在退出后无需重新登录即可返回到前几页?
检查会话是否为空 –
登录设置会话并注销表示如果会话为空,则取消会话重定向至index.php页面 – Ramki
http://www.makeitsimple.co.in/PHP_loginexmp.php –