View Single Post
Old 07-03-2008, 10:39 PM   #3 (permalink)
Tanax
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Actually, your script already works..?
It redirects IF the login was correct, otherwise it will print out that the username or password was incorrect.

Edit:

Ah, you want the logged in users to be redirected from login.php if they try to access it while logged in?
If so, you just do at the top of the script:
php Code:
<?

if($_SESSION['logged'] != 'yes') {

$u = $_POST['username']; //username from form
$p = $_POST['password']; // password from form.

if($u == "user1" && $p == "pass" ||
   $u == "user2" && $p == "pass" ||
   $u == "user3" && $p == "pass"){
 
      $_SESSION['user'] = $u;
      $_SESSION['logged'] = "yes"
      header("location:auth.php");
     
exit;
      }else{

      print "username or pass was incorrect";
   
     }
}

else {

header("Location: index.php");

}

     ?>

Obviously you edit the index.php to w.e page you want them to end up..
Tanax is offline  
Reply With Quote