Page 1 of 1

header()

Posted: Sun Sep 22, 2002 10:20 am
by Coco
just a quick question.... if im using header() to redirect from a page that needs to update a table and then pass 2 strings to the redirect page, can i put html form fields in before the header when they are hidden type?

if not would i have to put the results in another file?

Posted: Sun Sep 22, 2002 10:23 am
by nielsene
Forms will not submit on a header call, furthermore outputing forms before call header will generate a fatal error. The common ways to pass data when using header are to either encode the parameters into the query string of the URL or to use session variables.

You may want to also consider writing a function to wrap around header() if you are using sessions as transparent sessions do not currently attach the SID to local URLs in headers if cookies are not used for propagation..

Posted: Sun Sep 22, 2002 10:25 am
by twigletmac
From the manual entry for header():
php docs wrote:Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
Hidden form fields are still HTML tags and therefore count as output. If you need to have these before the header() function is called look into output buffering.

Mac

Posted: Sun Sep 22, 2002 10:53 am
by ~J~R~R
Using output buffering makes no sense. The output is buffered, but not not printed, because you use a header() before it, so the page is already redirected.

Posted: Sun Sep 22, 2002 11:36 am
by hob_goblin
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

look through it, it might have some POST header definitions...

other than that, you can try this:

1st) send it in get
2nd) grab the variables and cram them into a session
3rd) header the page to itself, without the get variables.

Posted: Mon Sep 23, 2002 10:07 am
by Coco
ok i started toying with sessions to get past this problem, now im finding that my redirect does nothing....

can header("Location: ") be used in frames?
and also does sending session variables count as sending content to the browser such as to break the header?
i dont even get a header error it just gives a blank page
and yes, im using a full address not relative

Posted: Mon Sep 23, 2002 10:17 am
by Coco
ho hum
:oops:
found my problem :cry:

Posted: Tue Sep 24, 2002 4:51 am
by twigletmac
What was your error? I ask simply so that anybody else who searches the forum and has the same problem doesn't have to ask the question again.

Mac

Posted: Tue Sep 24, 2002 4:55 am
by Coco
i had an error in my script which meant that i didnt even execute the header()

now you see why i was embarressed 8O