i have been trying to prevent user that are logged in not to go back to the login page. please i need your help. i've tried different method, but yet to no avail. i will be much grateful if anyone can help me. Thanks.
here is my php code for login
<?php
require 'connection.php';
session_start();
$_SESSION['message'] = '';
if(isset($_POST['login']))
{
if(empty($_POST['student']) || empty($_POST['pass']))
{
$_SESSION['message'] = " student id and password is required";
}
else
{
$password = md5($_POST['pass']);
$student = $_POST['student'];
$query= "select studentid, password, status from student_register where studentid='$student' and password='$password'";
$result=mysqli_query($conn, $query);
$row = mysqli_fetch_assoc($result);
if($row)
{
$_SESSION['user']=$_POST['student'];
$_SESSION['stat'] = $row['status'];
$_SESSION['message'] =" Login successfully";
header("refresh:5;url= Welcome.php");
}
else
{
$_SESSION['message'] =" Student id or password is incorrect";
}
}
}
else
{
}
?>