473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

cURL form submission without button + hand over control

1
I've spent HOURS searching the net for an answer to this, but can't find it...

I trying to send data using the POST method and also have the 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 after.

Here's my cURL example:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
  3.     $url = 'https://www.xyz.com/xyz.exe/xyz-AddItem';
  4.     $part1 = 'SB123';
  5.     $item1 = 'blue socks';
  6.     $qty1 = '1';
  7.     $price1 = 5;
  8.     $dat = "PartNo=".$part1."&Item=".$item1."&Qty=".$qty1."&price=".$price1."&";
  9.     $ch = curl_init();
  10.     curl_setopt($ch, CURLOPT_POST,1);
  11.     curl_setopt($ch, CURLOPT_POSTFIELDS,$dat);
  12.     curl_setopt($ch, CURLOPT_URL,$url);
  13.     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  1);
  14.     curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
  15.     curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  16.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
  17.     $result=curl_exec ($ch);
  18.     curl_close ($ch);
  19.     echo("Results: <br>".$result);
  20. ?>
Somehow I think it needs to redirect (hand over control) when the curl_exec function is called, because this is when the data would be POSTed (but I'm not an expert, so not sure).

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?

Any help would be appreciated.
Thanks
Jul 13 '07 #1
0 1571

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Tom | last post by:
I have created the following code for a product select/payment form (don't know if there is a better way) and I have been trying to make the following changes (unsuccessfully so far): 1) ...
19
by: Pete | last post by:
I have form/select which executes a function using onchange. No problem. However, when I validate the page with a strict HTML 4.01 doctype at http://validator.w3.org, it demands either an action or...
2
by: Brian | last post by:
On a photographer's web site, I have a catalogue page that lists all the photos available for purchase. It is marked up as a table, with 1 column for the image title, a second for the material on...
5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
3
by: John Dunlop | last post by:
(Note crosspost and follow-ups to ciwah.) Nicolas Keller wrote in thread "Differences in form handling btw Mozilla and IE?": > The problem: I'm using a form that submit's (POST) its data via...
2
by: Andy Goldstein | last post by:
I have a table where all the TRs have an onClick handler registered. One (and only one) of the rows has 2 text input boxes, where each textbox has an onChange handler registered. Both the onClick...
6
by: nick4soup | last post by:
I have read the CGI FAQ 'How can I avoid users hitting "submit" twice' (on http://www.htmlhelp.org/faq/cgifaq.3.html#19 ) which essentially says you have to detect it at the server, using a...
4
by: kschneider | last post by:
Assume there's a form with it's action attribute all set to post to a URL, but without a submit control. Form submission is done via a link and I want to prevent the classic "double submit"....
1
by: devranger | last post by:
I have used curl_setopt($ch, CURLOPT_POST, true); and curl_setopt($ch, CURLOPT_POSTFIELDS, $data); on post forms to retrun results, but what about a GET Form Method? How do you deal with these...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.