header("location:blaaaa.php") http 1.1 specificati

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
User avatar
fendtele83
Forum Commoner
Posts: 27
Joined: Tue Oct 25, 2005 2:21 pm
Location: Woodbridge, NJ

header("location:blaaaa.php") http 1.1 specificati

Post by fendtele83 »

ok, so here's my deal... i read/heard somewhere that if a user submits a form, and the watever.php file handles it... inserts the $_POST data into a database or watever it needs to do... then the watever.php file uses a header("location:blaaa.php"); statement that it's against strict http 1.1 specification...

is this true? is it good programming practice to use the header(location) combination after a user submits a form and the php hanldes the data?? what do you guys do?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

change it to header('Location: http://example.com/blaa.php'); and there's nothing to worry about...
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: header("location:blaaaa.php") http 1.1 specifi

Post by Roja »

fendtele83 wrote:ok, so here's my deal... i read/heard somewhere that if a user submits a form, and the watever.php file handles it... inserts the $_POST data into a database or watever it needs to do... then the watever.php file uses a header("location:blaaa.php"); statement that it's against strict http 1.1 specification...

is this true? is it good programming practice to use the header(location) combination after a user submits a form and the php hanldes the data?? what do you guys do?
There are a couple of different issues here.

First, the spec says that a header redirect (location) requires an absolute url - not a relative one. So, like timvw said, slap the FQDN on there, and you will be in compliance.

Now, the other issue you have is redirecting on a page that makes a change. Thats not "wrong" or non-compliant, but it can pose a problem. If a user browses, following your description, from form -> whatever.php, and then ends up on blaaa.php, it can confuse the user, prevent back-button browsing, and more.

Depending on how it is implemented, it can be no big deal, or very challenging for some users with assisted browsing technologies. My suggestion is to test it with eLinks (available on most unixes), and try browsing forward and back through the form submission process. If you can do both easily, you've probably designed it well enough.
User avatar
fendtele83
Forum Commoner
Posts: 27
Joined: Tue Oct 25, 2005 2:21 pm
Location: Woodbridge, NJ

thankssss

Post by fendtele83 »

thanks guys, im probably going to implement the location:with the full URL
Post Reply