Good day!
I have an index.php or login page, when i login successfully and when i accidentally press the back button the login page appear, then when i try to login again, I could login again which is not correct, I have no idea how can i prevent to login again if the userr is zalready login.
here is my php code:
I have an index.php or login page, when i login successfully and when i accidentally press the back button the login page appear, then when i try to login again, I could login again which is not correct, I have no idea how can i prevent to login again if the userr is zalready login.
here is my php code:
Code:
<?php
session_start();
if(isset($_SESSION['USER_ID'])){
exit("you can't login in again when your all ready logged!");
}
$db_name="dspi";
mysql_connect("localhost", "root", "") or die("Cannot connect to server");
mysql_select_db("$db_name")or die("Cannot select DB");
$department = mysql_real_escape_string($_POST['department']);
$username = mysql_real_escape_string($_POST['username']);
$sql=mysql_query("SELECT `Department`, `Username` FROM `tbllogin` WHERE `Department` = '{$department}' AND Username = '{$username}'") or die(mysql_error());
$ct = mysql_num_rows($sql);
if($ct == 1) {
$row = mysql_fetch_assoc($sql);
$Departments=array('Accounting', 'Engineering', 'Finishinh_Goods', 'HRAD', 'MIS', 'Packaging_and_Design', 'Production', 'Purchasing_Logistic', 'QA_and_Technical', 'Supply_Chain');
if(in_array($row['Department'], $Departments)){
header('Location:Company.php');
}else{
header('Location:index.php');
echo "Incorrect Username or Department";
}
}
?>
Comment