blink359 Posted November 21, 2010 Share Posted November 21, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/219390-login-script-wont-take-the-user-to-restricted-page/ Share on other sites More sharing options...
BlueSkyIS Posted November 21, 2010 Share Posted November 21, 2010 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"; } Quote Link to comment https://forums.phpfreaks.com/topic/219390-login-script-wont-take-the-user-to-restricted-page/#findComment-1137600 Share on other sites More sharing options...
blink359 Posted November 21, 2010 Author Share Posted November 21, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/219390-login-script-wont-take-the-user-to-restricted-page/#findComment-1137615 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.