PHP/CURL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
misslilbit02
Forum Newbie
Posts: 9
Joined: Mon Sep 18, 2006 3:57 pm

PHP/CURL

Post by misslilbit02 »

I'm receiving HTTP POST and I need to send a response back saying wether or not I got the post sucessfully or not. I also need to redirect to a confirmation page.

I was using CURL to develop this. But seems like nothing was being sent.

Every vendor keeps sending me information like this:
*****************************************************
leads[0] : lead_id = 6145194, partner_id = 592, campaign_code =



POST /vendor_script.php HTTP/1.0
Host: [URL]
Content-Length: 293
User-Agent: Mozilla/4.0 (compatible; MSIE 4.0;Mac_PowerPC)
Content-Type: application/x-www-form-urlencoded



firstname=Clifton&middlename=&lastname=Webb&suffix=&email=fred643%40
comcast.net&home=313-673-9403&work=313-322-3002&other=&program=CJAA&
address1=9178+Cameron+St+&city=DETROIT&state=MI&zip=48211&age=25&
expectedstart=immediately&education=Some+College&gradyear=1981&comments=&form=MonsterNetwork



HTTP/1.1 200 OK
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: PHP/5.2.0
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Date: Fri, 02 Nov 2007 00:02:45 GMT
Connection: close


Then the confirmation page that I print out for the user is typically at the end of all this information.

How do send a reponse back? It seems this is done by printing out something and I print a confirmation page but they're looking for a server response. Can somebody help me with this?
Apocalypz
Forum Newbie
Posts: 6
Joined: Fri Nov 02, 2007 2:54 pm

Post by Apocalypz »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


This should work for your needs. Make sure your server is configured to use the cUrl function. If you have any questions let me know.

Code: Select all

// The data you are sending them
$newform = "firstname=Clifton&middlename=&lastname=Webb&suffix=&email=fred643%40
comcast.net&home=313-673-9403&work=313-322-3002&other=&program=CJAA&
address1=9178+Cameron+St+&city=DETROIT&state=MI&zip=48211&age=25&
expectedstart=immediately&education=Some+College&gradyear=1981&comments=&form=MonsterNetwork";

// The URL that the client needs to be notified at
$url = "http://www.somedummysite.com/notifier.php";

// Set up the curl function and execute
$curl = curl_init();
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $newform);
curl_setopt($curl, CURLOPT_URL, $url);
curl_exec($curl);
curl_close($curl);

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Post Reply