PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Sun May 28, 2006 9:58 pm
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.
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Mon May 29, 2006 4:20 am
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...
$phpNut
Forum Commoner
Posts: 40 Joined: Tue May 09, 2006 5:13 pm
Post
by $phpNut » Mon May 29, 2006 5:35 am
You need to put single or double quotes in your header()'s.
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Mon May 29, 2006 7:24 am
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?
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Mon May 29, 2006 10:28 am
You'll need to start the session with session_start(), but otherwise, that's correct.
a94060
Forum Regular
Posts: 543 Joined: Fri Feb 10, 2006 4:53 pm
Post
by a94060 » Mon May 29, 2006 10:39 am
ok,so i will need to make sure on everypage i call session_start()