Page 1 of 1

Header() POSTed variables

Posted: Mon Nov 03, 2003 7:23 pm
by Gen-ik
This is more of a curiosity question than anything but I was wondering if it is possible to force variables to be POSTed from PHP?

An example might be if the index.php page of your site was accessed and you wanted to send the user to page X with a variable, but send along a POST variable with the redirecting instead of a GET variable.

Another example might be if someone attempted to log-in to their account but the username or password was invalid. PHP would the bounce the user back to the page they came from with the error message variable as POST and not tagged onto the end of the URI with GET.

I'm not too sure if this can be done with header() or not... or if it can be done at all.

Re: Header() POSTed variables

Posted: Mon Nov 03, 2003 7:36 pm
by scorphus
Gen-ik wrote:or if it can be done at all.
You can use a form with hidden fileds and use javascript to submit it.

But with header()... ca't help you yet.

Cheers,
Scorphus.

Posted: Mon Nov 03, 2003 7:39 pm
by m3mn0n
Yeah, I was thinking the same thing. meta refresh + hidden fields + javascript submit.

Posted: Mon Nov 03, 2003 7:54 pm
by Gen-ik
Doh. Oh well, I'll just use a session variable instead.

Posted: Mon Nov 03, 2003 7:57 pm
by hedge
I have done it using sockets. Do a search for my username, I've posted the code a few times.

I had to go a step furthur and login to another site as well and then keep sending the authentication cookie along.

Posted: Mon Nov 03, 2003 8:00 pm
by scorphus
Gen-ik wrote:Doh. Oh well, I'll just use a session variable instead.
Yeah, I thought of that, but assumed you have already thought it too and wanted to do it using $_POST. Using sessions will be that easy...

Scorphus.

Posted: Mon Nov 03, 2003 8:02 pm
by hedge
Found the link viewtopic.php?t=7063

BTW the function 'httpParseResponse' in my code is incorrect. It explodes by \r\n\r\n when it should just split the headers from the content at the first occurrance of \r\n\r\n