У меня есть страница входа.используя сеанс, пользователь может войти в index page.но после входа в систему пользователь входит в index page и если я щелкаю страницу обратно в chrome, то она всегда возвращается в предыдущую форму входа. Я не понимаю, в чем заключается ошибка в моем коде. как решитьэта ошибка?
login-submit.php page----
<?php
require 'includes\common.php';
$email = $_POST['e-mail'];
$email = mysqli_real_escape_string($con, $email);
$password = $_POST['password'];
$password = mysqli_real_escape_string($con, $password);
$password = MD5($password);
// Query checks if the email and password are present in the database.
$query = "SELECT id, email FROM admin WHERE email='" . $email . "' AND password='" . $password . "'";
$result = mysqli_query($con, $query)or die($mysqli_error($con));
$num = mysqli_num_rows($result);
// If the email and password are not present in the database, the mysqli_num_rows returns 0, it is assigned to $num.
if ($num == 0) {
$error = "<span class='red'>Please enter correct E-mail id and Password</span>";
header('location: login.php?error=' . $error);
} else {
$row = mysqli_fetch_array($result);
$_SESSION['email'] = $row['email'];
$_SESSION['user_id'] = $row['id'];
header('location: index3.php');
}
login.php page----
<?php
include 'includes\common.php';
// Redirects the user to products page if logged in.
if (isset($_SESSION['email'])) {
header('location: ');
}
?>
index.php page----
<?php
$con = mysqli_connect("localhost", "root", "", "store") or die(mysqli_error($con));
if(!isset($_SESSION))
{
session_start();
}
require 'includes\header.php';
if(isset($_POST['search']))
{
$valueToSearch = $_POST['valueToSearch'];
// search in all table columns
// using concat mysql function
$query = "SELECT * FROM `users` WHERE CONCAT(`id`, `Name`, `email`, `password`, `contact`, `city`, `address`) LIKE '%".$valueToSearch."%'";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM `users`";
$search_result = filterTable($query);
}
// function to connect and execute the query
function filterTable($query)
{
$connect = mysqli_connect("localhost", "root", "",'store');
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
?>