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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.