我是一个创建网站的初学者,我还在练习使用PHP休息室制作网站。
这是我面临的问题,如果我点击后退按钮我还在登录页面上,我该如何删除登录表单?
我从我的数据库登录的php代码
$member_email = $_POST["member_email"];
$member_password = md5($_POST["member_password"]);
require_once("db_open.php");
$sql = "SELECT * FROM members WHERE member_email='".$member_email."' AND member_password='".$member_password."'";
$result = $conn->query($sql) or die($conn->error);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
session_start();
$_SESSION["member_id"] = $row["member_id"];
$_SESSION["member_email"] = $row["member_email"];
$_SESSION["member_full_name"] = $row["member_full_name"];
}
} else {
header("Location: login_form.php");
exit();
}
require_once("db_close.php");
header("Location: index.php");
?>
我检查登录信息的代码
<?php
if (!isset($_SESSION["member_id"])) {
exit("<h3>Please <a class='btn btn-primary' href='login_form.php'>login</a> first.</h3>");
}
?>
这是我的HTML和登录表单
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>All Members</title>
<link rel="stylesheet" href="bootstrap.min.css" />
</head>
<body>
<?php require_once("top_nav.php"); ?>
<div class="container">
<h1>Login</h1>
<form method="POST" action="login_db.php">
<div class="form-group">
<label for="member_email">Email:</label>
<input type="text" name="member_email" id="member_email" class="form-control" />
</div>
<div class="form-group">
<label for="member_password">Password:</label>
<input type="password" name="member_password" id="member_password" class="form-control" />
</div>
<button type="submit" class="btn btn-success btn-lg">Login</button>
</form>
</div>
</body>
</html>