Can someone help on how I can do to submit form data (POST) to URL using PHP and cURL?
Using cURL, all I want to do is send the data, I don’t want to be redirected and not get any result (HTML or TEXT), just send the data.
It would be nice to know if the data was sent successfully or the error or redirection was not processed.
Additional Information. The reason I think I am being redirected is that as soon as I execute cURL, the landing page, which is a third-party website, is redirected to the place, confirming that the user received their data, and for some reason the reason that when I send my data using cURL, their redirection affects my page, so my page is also redirected to the confirmation site.
Thanks to everyone.
Code example:
$sub_req_url ="http://domain.com/util/request";
$ch = curl_init($sub_req_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, "id=64&session=1&k=B0EA8835E&firstname=Name&lastname=Lastname&company=Company%20Name&email=me@gmail.com&work_phone=123-456-7890");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
$resp = curl_exec($ch);
curl_close($ch);
I am editing this post to show an example of what I am using. I have to publish the code in the first place.
source
share