Adding POST data to a redirect?
Moderator: General Moderators
-
andrewcarraway
- Forum Newbie
- Posts: 9
- Joined: Fri May 02, 2003 1:54 pm
Adding POST data to a redirect?
I am trying to redirect a page using header("Location: [URL]");
I would like to add POST data to the redirect, in other words, I want to send information to along to the next page as if I had submitted it to that page in a form. Any ideas?
Thanks!
Andrew
I would like to add POST data to the redirect, in other words, I want to send information to along to the next page as if I had submitted it to that page in a form. Any ideas?
Thanks!
Andrew
-
pascalganaye
- Forum Newbie
- Posts: 3
- Joined: Fri May 02, 2003 2:10 pm
- Location: BATH - UK
- Contact:
You can do it with javascript
I don't know if it helps,
I wanted to login in phpbb without displaying the form.
I managed to do it this way :
This does a fake redirect with forced POSTED values
I wanted to login in phpbb without displaying the form.
I managed to do it this way :
Code: Select all
$HTTP_POST_VARSї'username'] = $username;
$HTTP_POST_VARSї'login'] = "Connexion";
$HTTP_POST_VARSї'redirect'] = "";
$HTTP_POST_VARSї'autologin'] = "false";
$password = $row->password;
$HTTP_POST_VARSї'password'] = $password;
chdir("../phpBB2/");
include('login.php');-
andrewcarraway
- Forum Newbie
- Posts: 9
- Joined: Fri May 02, 2003 1:54 pm
Maybe I wans't very clear... here is some more information:
I want to send information to a redirected page via POST. I can do it via GET by tagging all the information to the url in the querystring, like this:
header("Location: sample.php?test=true");
(In this example I am sending the paramater of 'test' with the value of 'true'.)
My problem is that the page I am trying to redirect to will not accept data that is sent through the GET method. It will only accept POST, so I am asking if anyone knows how to add the POST data to the redirect, as if I had sent the information by submitting a form.
Thanks again,
Andrew
I want to send information to a redirected page via POST. I can do it via GET by tagging all the information to the url in the querystring, like this:
header("Location: sample.php?test=true");
(In this example I am sending the paramater of 'test' with the value of 'true'.)
My problem is that the page I am trying to redirect to will not accept data that is sent through the GET method. It will only accept POST, so I am asking if anyone knows how to add the POST data to the redirect, as if I had sent the information by submitting a form.
Thanks again,
Andrew
Pretty simple stuff...
Grab the information from the POST like so:
Code: Select all
$linkname = $_POST['name_of_field_you_are_entering_info_in'];
header ("Location: http://www.yoursi.te/$linkname");-
andrewcarraway
- Forum Newbie
- Posts: 9
- Joined: Fri May 02, 2003 1:54 pm
Hmm... the example I gave you won't work unless you actually use a form to transmit the data. And since you can't change the code on this other server anyway, you wont' be able to adjust the code to do what you want it to.
Even if you could send information as if you had POSTed it, the page you're sending the information to has to be set up to receive the information.
Chances are, since you aren't editing the script, it's not set to do that. Why in the world are you trying to access a script you don't have control of anyway?
Even if you could send information as if you had POSTed it, the page you're sending the information to has to be set up to receive the information.
Chances are, since you aren't editing the script, it's not set to do that. Why in the world are you trying to access a script you don't have control of anyway?
-
pascalganaye
- Forum Newbie
- Posts: 3
- Joined: Fri May 02, 2003 2:10 pm
- Location: BATH - UK
- Contact:
You could perhaps generate a page who will post automatically the value you want to post :
Code: Select all
<body onload="javascript:document.form1.submit();">
<form action="http://ww.otherserver.com/post.php?xx=4&yy=2" method="post" name="form1">
<input name="value1" type="hidden" value="0">
<input name="value2" type="hidden" value="1">
</form>-
andrewcarraway
- Forum Newbie
- Posts: 9
- Joined: Fri May 02, 2003 1:54 pm
We are integrating our shopping cart system with a third party. They need the information sent through a form, but before we send it along, I need to capture it and process it. (I don't know why they do it that way, but they just do and I have to figure out a way to deal with it.)
It doesn't look like there is any way to do this, at least nobody seens to know. I have done something similar in ASP, where you add the POST data to the header of the redirect... but it doesn't look like there's a way to do that in PHP.
Andrew
It doesn't look like there is any way to do this, at least nobody seens to know. I have done something similar in ASP, where you add the POST data to the header of the redirect... but it doesn't look like there's a way to do that in PHP.
Andrew
-
andrewcarraway
- Forum Newbie
- Posts: 9
- Joined: Fri May 02, 2003 1:54 pm
Maybe this should be a sticky, it seems like I am providing this link every week.
At the bottom is some code I posted with some functions to simulate a post
viewtopic.php?t=7063
At the bottom is some code I posted with some functions to simulate a post
viewtopic.php?t=7063