faqts : Computers : Programming : Languages : PHP : Common Problems : HTTP Headers

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 8 people (75%) answered Yes
Recently 1 of 3 people (33%) answered Yes

Entry

How to put form-passed args into bookmarkable address

Feb 27th, 2000 02:10
John Clements,


When a visitor chooses a new page on your site by clicking on a link you 
have set up, the link will include all the arguments required to 
identify what page to (create and) send.  If the visitor uses a form to 
choose a page, the form variables are passed via the post method and 
don't appear in the "Location" header sent to the browser with the 
requested page, so if the visitor bookmarks that page, the bookmark will 
lead back to your php3 file with no arguments given.

How do you put into the "Location:" header all the information that is 
needed to enable the user to bookmark a particular page?  This exercised 
me for several days and I poured through the http 1.1 spec and the php 
manual to no avail. (Just sending a new "Location" header doesn't work.)

I finally solved it through brute force with:


header ("Request-URI: 
http://www.publicinfo.net/pic.php3?allvars=$allvars");

header ("Content-Location: 
http://www.publicinfo.net/pic.php3?allvars=$allvars");

header ("Location: 
http://www.publicinfo.net/pic.php3?allvars=$allvars");


If you send these headers in this order, it works! If you just send the 
"Location" header or send it first, the browser gets a 301 Found!, which 
is worse than useless.