Page 1 of 1
headers problem
Posted: Sun May 28, 2006 9:58 pm
by a94060
WEll i have this peice of code here in my script:
Code: Select all
<?PHP
$user = $_POST['you'];
$pass = $_POST['me'];
if(($user == 'XXX') && ($pass == 'XXX')) {
$_SESSION['in'] == TRUE;
header(Location: ../admin/tabview.php ); //if the username and pass match go to the tabview page
}
else{
header(Location: ../admin ); //if not send back to login page
}
?>
im not sure what is wrong,i get an error about the : that is in there.
Posted: Mon May 29, 2006 4:20 am
by timvw
1-) You can redirect users, by sending out a location
http://www.php.net/header. As you can read in the manual this function accepts a string. Eg:
Code: Select all
header('Location: http://example.com');
2-) Before you do the redirection, you should call
http://www.php.net/session_write_close in order to make sure that the session data is stored...
3-) You should not use relative URLs for redirection.. There are browsers that don't handle them well...
Posted: Mon May 29, 2006 5:35 am
by $phpNut
You need to put single or double quotes in your header()'s.
Posted: Mon May 29, 2006 7:24 am
by a94060
Say i do a session like this
will that value go onto to other pages that are within the site?for example,can i call it on another page like
Code: Select all
if($_SESSION['in'] == 'yes') {
echo 'This is right';
}
that will work?
Posted: Mon May 29, 2006 10:28 am
by Ambush Commander
You'll need to start the session with session_start(), but otherwise, that's correct.
Posted: Mon May 29, 2006 10:39 am
by a94060
ok,so i will need to make sure on everypage i call session_start()