Page 1 of 1

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

Posted: Thu Jan 12, 2006 3:14 pm
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?

Posted: Thu Jan 12, 2006 3:25 pm
by timvw
change it to header('Location: http://example.com/blaa.php'); and there's nothing to worry about...

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

Posted: Thu Jan 12, 2006 3:52 pm
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.

thankssss

Posted: Thu Jan 12, 2006 8:04 pm
by fendtele83
thanks guys, im probably going to implement the location:with the full URL