I'm having trouble with a script that I see as simple 😐
I'm only trying to make it so that if you are correct, you are moved to the index.php page, if you are admin authorised, you go to /admin... although if your username is non existant the script does nothing....
any better methods are welcomed with open arms anyway, but if anyone is able to sort this out I'll be double happy.
I'd like to know what I'm screwing up.
cheers.
<?
if(isset($HTTP_GET_VARS['action'])){
$action = $HTTP_GET_VARS['action'];
switch($action){
case "logout":
session_start();
session_unregister('user');
if(!headers_sent()){
header("Location: index.php");
}
exit;
}
}
include("include.php");
$query = "SELECT username, password, auth FROM users";
$result = MYSQL_QUERY($query, $conn);
if(!$result){
die(MYSQL_ERROR());
}
while(list($username, $password, $auth) = MYSQL_FETCH_ARRAY($result)){
if($username == $_POST['user']) {
if($password == $_POST['pass']){
session_start();
session_register("user");
$user = $username;
if($auth == "admin"){
header("Location: admin/");
}else{
if($_SESSION['location']){
header("Location: " . $_SESSION['location']);
}else{
header("Location: index.php");
}
}
}else{
header("Location: login.php");
}
}else{
header("Location: login.php");
}
}
?>