Jump to content

login script wont take the user to restricted page


blink359

Recommended Posts

My login script wont take my users to the restricted page and im not quite sure why it must be the header because it echos"wrong username or password" when i put in the wrong username or password here is my code:


if($count==1 & $row['flight']=="vulcan"){
session_start(vmyusername); 
session_start(vmypassword);  
header("location:/vulcan/index.php");
}else if($count==1 & $row['flight']=="valiant"){
session_start(myusernamev); 
session_start(mypasswordv);  
header("location:valiant/index.php");
}else
{
echo "Wrong Username or Password";
}
}
?>

Any help would be much appriciated

 

Thanks,

 

Blink359

Link to comment
Share on other sites

you might want to consider looking into some session tutorials and examples.

 

http://www.google.com/search?client=safari&rls=en&q=php+session+tutorial&ie=UTF-8&oe=UTF-8

 

this might not work, but it is closer than what you've got

 

session_start();

if ($count==1 && $row['flight']=="vulcan") {
     $_SESSION['vmyusername'] = $row['vmyusername'];
     $_SESSION['vmypassword'] = $row['vmypassword']; 
     header("location:/vulcan/index.php");
     exit;
}else if($count==1 && $row['flight']=="valiant"){
     $_SESSION['vmyusernamev'] = $row['vmyusername'];
     $_SESSION['vmypasswordv'] = $row['vmypassword']; 
     header("location:valiant/index.php");
     exit;
}else{
     echo "Wrong Username or Password";
}

Link to comment
Share on other sites

Sorted my headers but that code and my session code doesnt restrict the user from accessing the other content

session start

if($count==1 & $row['flight']=="vulcan"){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start(vmyusername); 
session_start(vmypassword);  
header("location:vulcan/index.php");
}else if($count==1 & $row['flight']=="valiant"){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_start(myusernamev); 
session_start(mypasswordv);  
header("location:valiant/index.php");
}else
{
echo "Wrong Username or Password";
}

check session:

<? 
session_start();
if(!session_is_registered(vmyusername)){
header("location:../login.php");
}
?>

//OR

<? 
session_start();
if(!session_is_registered(myusernamev)){
header("location:../login.php");
}
?>

What do i do?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.