Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
08-13-2008, 12:20 PM #1
Supplying a page with $_POST data follwing a server-side redirect
The following example will make the variables x and y available in mypage.php as $_GET data:
header ("Location: mypage.php?x=1&y=2");
EDIT: I know I can mimick this using $_SESSION, but I wonder if there is a neat way of incorporating it into a request before the redirect (which ellicits a response) so that I don't have to do it explicitly with $_SESSION.
Last edited by mlse; 08-13-2008 at 12:31 PM.
08-13-2008, 12:32 PM #2
08-13-2008, 12:41 PM #3
Yep, thanks, I know that will work, but I would like to do it purely server-side.
08-13-2008, 12:51 PM #4
- Join Date
- Mar 2007
- Northamptonshire, UK
- Thanked 4 Times in 4 Posts
I cannot think of a way to do this with just the header() function but you could use cURL to send the POST data.
Then you don't even have to leave the page, i don't know if this is exactly what you were looking for but...
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_POST, 1);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://www.example.com/page.php?x=hello&y=goodbye");
curl_setopt ($ch, CURLOPT_HEADER, 0);
08-13-2008, 02:18 PM #5
Hi, yep I had thought of that, but I think the $_SESSION solution is easier. I'll stick with $_SESSION until someone comes up with something else!