Header problem

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

Post Reply
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Header problem

Post by kkonline »

Below is the extract of the problem part of the else loop. It gives me a parse error for the header line, the url is send from the previous page and is available as $_POST['url'] in general throughout the processing script.

Code: Select all

else
{
header( refresh: 2; url=$_POST['url'] );
  echo 'Message has been sent.';

}
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Of course

Code: Select all

header('refresh: 2; url='.$_POST['url']);
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Post by kkonline »

miro_igov wrote:Of course

Code: Select all

header('refresh: 2; url='.$_POST['url']);
that means argument to header() is a string.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Yes, click on the header in the PHP snippet of your post and you will read about this function.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

The contents of a header() call are not the same as that of a meta tag.

If you want to wait 2 seconds before loading the next page.. you have two options.

1:

Code: Select all

sleep(2); //sleep two seconds
header('Location: ' . $_POST['url']);
2: Generate an HTML page with a meta tag like the header you're currently trying to send.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
kkonline
Forum Contributor
Posts: 251
Joined: Thu Aug 16, 2007 12:54 am

Post by kkonline »

scottayy wrote:The contents of a header() call are not the same as that of a meta tag.

If you want to wait 2 seconds before loading the next page.. you have two options.

1:

Code: Select all

sleep(2); //sleep two seconds
header('Location: ' . $_POST['url']);
2: Generate an HTML page with a meta tag like the header you're currently trying to send.
Scottayy is there anything wrong if i use

Code: Select all

header('refresh: 2; url='.$_POST['url']);
any bug or any reason for which i should not use it, and use

Code: Select all

sleep(2); //sleep two seconds
header('Location: ' . $_POST['url']);
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The refresh header is non-standard, and only supported by a few servers/browsers.
Post Reply