Header() POSTed variables

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
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Header() POSTed variables

Post 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.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Re: Header() POSTed variables

Post 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.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yeah, I was thinking the same thing. meta refresh + hidden fields + javascript submit.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Doh. Oh well, I'll just use a session variable instead.
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post 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.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post 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.
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post 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
Post Reply