By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,516 Members | 1,153 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,516 IT Pros & Developers. It's quick & easy.

is it possible to have more than one header(location: );

P: 24
is it possible to have more than one header(location: );

or can i have one
header('Refresh: 3; url=login.php');
and
echo header('location: index.php');
Jul 26 '07 #1
Share this Question
Share on Google+
4 Replies


pbmods
Expert 5K+
P: 5,821
Heya, fruityfreak.

To do that, redirect to login.php?target=index.php, and then have login.php redirect to $_GET['target'].
Jul 26 '07 #2

P: 24
what do u mean by that??
Jul 26 '07 #3

pbmods
Expert 5K+
P: 5,821
Heya, fruityfreak.

what do u mean by that??
In other words, if you wanted to (I'm assuming) log the User out, you could do this:

Expand|Select|Wrap|Line Numbers
  1. header('Location: login.php?target=index.php');
  2. exit();
  3.  
Which would pass 'index.php' as the value of $_GET['target'] to login.php.

And then at the bottom of login.php:
Expand|Select|Wrap|Line Numbers
  1. if(! empty($_GET['target']))
  2. {
  3.     header('Location: ' . $_GET['target']);
  4. }
  5. else
  6. {
  7.     header('Location: someDefaultLocation.ext');
  8. }
  9. exit();
  10.  
Jul 26 '07 #4

kovik
Expert 100+
P: 1,044
With absolute URLs as the Location header directive. ;)
Jul 26 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.