cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

post operation does not return any results

From: Pras <pras_at_linux.ca>
Date: Mon, 27 May 2002 21:01:14 EDT

I have searched the archives for topics relating to my problem but I haven't found what I need.

I have a site hosted on a virtual server. Both curl (GET method) and php are working properly. I'm having a problem with getting a response when I use a curl POST operation.

I have 2 scripts. One sends a variable via a post operation through curl to another script. The second script contains an if structure to evaluate the content of the variable, and it should return a string based on that. here are the 2 scripts:

***********************************************
page2.php - the one that uses curl
------------------------------------
<?php
$ch = curl_init ("page3.php");

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "test=inprogress");
$result = curl_exec ($ch);
curl_close ($ch);

echo $result;
?>

page3.php - the script that processes the data
----------------------------------------------
<?php
if ($_POST['test'] == 'inprogress')
{
  return 'test is in progress';
}
else
{
  return 'not working';
}
?>
*************************************************

In page2.php, nothing is output when the echo $result; line is encountered. I also tried echoing instead of returning a string in page3.php. Additionally, I tried writing output to a file in page3.php but none of these methods worked. Nothing is written to the file.

Apparently, the page3.php script isn't even being executed. Is this what is supposed to happen? How can I obtain a result of the post operation?

Thanks,
Pras

___________________________________
Get YOUR Unlimited E-mail and Web Space at http://www.crosswinds.net/

AS SEEN ON NATIONAL TV: http://fortunemaker.net/tv/html/19712.html

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
Received on 2002-05-28