session_start();
// $_SESSION['time'] = time();
/* Check User Script */
include 'db.php';
// Convert to simple variables
$username = $_POST['username'];
$password = $_POST['password'];
if((!$username) || (!$password)){
echo "Please enter the required information - UserName and Password!
";
include 'Login.htm';
exit();
}
// Convert password to md5 hash
$password = md5($password);
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$_SESSION['usersid'] = $userid;
$_SESSION['usersname'] = $username;
$StudentID = $userid;
mysql_query("UPDATE users SET last_login=now() WHERE userid='$StudentID'");
if ($username == "Administrator"){
$target = "http://www.TMGDataSystems.com/EXTRACOM.htm";
}
else{
$target = "http://www.TMGDataSystems.com/Login.htm";
}
// header("Location: " . $target . $urlpage);
header("Location: " . $target);
}
} else {
echo "You could not be logged in! Either your Username or Password are invalid!
Please try again...
";
include 'Login.htm';
}
?>