jsherk Posted July 13, 2007 Share Posted July 13, 2007 I've spent HOURS searching the net for answer to this, but can't find it... I'm trying to send data using the POST method and also have control of the browser be turned over to the website that's receiving the POST data (note that this is NOT the same as sending the data via POST method and then redirecting to the website after). I need it to work exactly like hitting the submit button on an html form, and I need it to work from PHP. It needs to POST the data to the site and also let the other site have control at the same time. I've tried a couple of methods using both cURL and an fsocket function, but it seems like in both cases that (1) the data gets sent to the other site first, (2) then my program gets a response back, (3) and then it redirects to the other site afterwards. The data gets sort of POSTed to the other site (I get a 200 response back, and I get info showing it was posted correctly), but since the other site does not get control, it seems to dump (not save) the posted data. Here's my cURL example: <?php $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"; $url = 'https://www.xyz.com/xyz.exe/xyz-AddItem'; $part1 = 'SB123'; $item1 = 'blue socks'; $qty1 = '1'; $price1 = 5; $dat = "PartNo=".$part1."&Item=".$item1."&Qty=".$qty1."&price=".$price1."&"; $ch = curl_init(); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS,$dat); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); $result=curl_exec ($ch); curl_close ($ch); echo("Results: <br>".$result); ?> Somehow I think it needs to redirect (hand over control) exactly when the curl_exec function is called, because this is when the data would be POSTed. Is there a way to terminate my php program AND hand the browser over to this other site AND pass the data over using the POST method, all at the exact same time? I tried: header ("Location: https://www.othersite.com); exit(); But this also seems to POST the data first, and then redirects to the other site after, which has the same effect of my POSTed data being dumped. Any help would be appreciated. Thanks Quote Link to comment Share on other sites More sharing options...
php4ever Posted October 25, 2007 Share Posted October 25, 2007 Look at this http://www.troywolf.com/articles/php/class_http/ Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted October 25, 2007 Share Posted October 25, 2007 If you set the option followlocation to true, then the data you get back from the other site should be where ever you would normally end up. This would create the appearance of actually being on the other website. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.