Jump to content

HTTP POST with CURL


misslilbit02
 Share

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
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
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.