Asynchronous Server Side Post

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
virdei
Forum Newbie
Posts: 8
Joined: Mon Sep 13, 2004 10:02 am

Asynchronous Server Side Post

Post by virdei »

:?:

I have a php page that will receive some variables from a form. I want this php page to then do an asynchronous server side post of some new variables to a third php page. I have done this before in vbscript but I can't seem to find a way to do this in PHP.

Page 1: has a form that will post some variables
Page 2: will receive this variables and post some new variables to a third php page. The post done from this page must be an asynchronous server side post. The post must be done from the php script.
Page 3: will receive the post from page 2 and this page is never seen by the end user.

I have done this before using vbscript but I can't replicate it with PHP. Below is my code in vbscript.

<%
xSeconPostValue = "variablename=variablevalue"

Set objHTTP = server.CreateObject("Microsoft.XMLHTTP")
objHTTP.open "post", "url"
objHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
objHTTP.send xSecondPostValue
%>

So the second page will post the values to the third page and this will be done asynchronously. This is all done in the server side so all actions are hidden to the end user.

Any help with this is greatly appreciated
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Why do you need to do this ?

You seem to be adding extra work for no return.. The middle "page" needs to be called, downloaded just for the third page to work...

If you simply need to process additional variables place them in the code for your third (my second) php script. If you process the first page's values you can hide them from the user regardless.

You may want to look at PHP command "header", but as far as I am aware you can not send POST values with it. (Try a search as I am pretty sure this has been discussed before).
virdei
Forum Newbie
Posts: 8
Joined: Mon Sep 13, 2004 10:02 am

Post by virdei »

The reason I need to do this is because the second page and the third page are in two different locations at two different ip addresses. The second page will execute some code and make that post to the third page which will then execute another code in that server.

So basically, page 2 will run some code on server 2 in location 2 and then it will post some variables to page 3 and this page will run some code in server 3 in location 3. Hence, why i need the asynchronous server side post.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

As I said searching on the forum may help you find what you need...

viewtopic.php?t=25500&highlight=send+post

Found with key words "send POST" with "Search for all terms" checked.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

check out the [php_man]curl[/php_man] extension
virdei
Forum Newbie
Posts: 8
Joined: Mon Sep 13, 2004 10:02 am

Post by virdei »

if you have information on how i can do this using curl it would be much appreciated. Curl does seem to be like the best option but it seems a bit more complex to learn and understand. If you have code samples that would be very helpful.
virdei
Forum Newbie
Posts: 8
Joined: Mon Sep 13, 2004 10:02 am

Post by virdei »

I made some tests using curl and it is a much better option. Thanks for the help.
Post Reply