Jump to content

HTTP POST with CURL


misslilbit02

Recommended Posts

I'm receiving post from various vendors...and I'm trying to send a response back to them saying whether I received the post sucessfully or not. My thoughts were to use CURL. I'm not totally clear as to how I should handle this but this is what I did. I collected the info posted to one page then via CURL I redirected the information to another page that says wether or not the the post was successful and based on wether it was successful or not then the script is redirected to a confirmation page.

 

My biggest issue is I'm trying to send a response to the server that posted to me saying wether or not the post was successful.

 

Can someone please direct me in the right direction?

Link to comment
https://forums.phpfreaks.com/topic/74350-http-post-with-curl/
Share on other sites

Can someone give me an example on how to do this because this isn't working for me and i"ve never done this before.

 

$request = '';
foreach ($_GET as $key => $value) {
$value = urlencode(stripslashes($value));
if ( $body != '' ) {
$body.= '&';
}
$body.= "$key=$value";
}

$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, '[url]' );
	curl_setopt($ch, CURLOPT_HEADER, 1);
	curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
	$output = curl_exec($ch);
	curl_close($ch);


if (strstr($output, "Success") ) {

            header("[url]");
}

else {

            header("[url]");
	}

 

Where do I send the response in all of this?

Link to comment
https://forums.phpfreaks.com/topic/74350-http-post-with-curl/#findComment-375705
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.