Sending POST variables through header(location..?

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
fjonte
Forum Newbie
Posts: 2
Joined: Wed Dec 18, 2002 9:00 am

Sending POST variables through header(location..?

Post by fjonte »

What I would like to do is something like this:

Code: Select all

header("Location:index.php?message=".$message."&id=".$id);
but I want to have lots of variables, and I want to send them like $_POST variables, not like $_GET.

Or maybe create a form and posting it, but without sending it to the client first.

I would also like to do stuff like add a target="_blank" somewhere.

Is there any way to do this?
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

You can't really do target="_blank" but you can do another one:-
You could use for and loop it. Put all the name of the value into an array and loop that variable.
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

You could submit a post over a socket connection but you would have to build the html headers yourself.

I have seen an example on the php.net site, I believe it's under fsockopen()
kcomer
Forum Contributor
Posts: 108
Joined: Tue Aug 27, 2002 8:50 am

Post by kcomer »

why not store all the variables in an array and store the array as a session variable. Then just call the session variable on the page you redirected to and then kill the session variable once you don't need it.
persaltier
Forum Newbie
Posts: 3
Joined: Wed Dec 18, 2002 10:50 pm
Location: NYC

Post by persaltier »

instead of worrying about arrays....store each variable as a session variable before redirecting the user using the header() function, then initiate the session on the subsequent page and grab at the stored session vars.

Code: Select all

<?php
while(list($k, $v) = each ($_POST)){		//add all POST variables to the SESSION
	$_SESSION[$k] = $v;
	}
?>

change $_POST to whatever method you've used to get to the page you're on that will be supplying the header() function.
?>
superwormy
Forum Commoner
Posts: 67
Joined: Fri Oct 04, 2002 9:25 am
Location: CT

Post by superwormy »

I too want to do this... what does an HTTP header for post variables actually look like?

I dont' mind building the HTTP headers myself...
Post Reply