curl-users
CURLOPT_POSTFIELDS not working for me
Date: Thu, 05 Feb 2009 09:13:56 -0800
Programming c with Codeblocks 8.02 on Windows XP Professional, libcurl
7.19.2, PHP version 5.2.6
I don't know if this is a bug or an error on my part, probably the latter.
simple php code on website (curltest.php):
<script language="php">
if(isset($_GET['testcode']))
$p_code = $_GET['testcode'];
else
$p_code = 0;
if($p_code)
print("success with testcode = $p_code");
else
print("failure");
</script>
c code:
curl_easy_setopt(hcurl, CURLOPT_URL,
"http://www.mywebsite.com/curltest.php");
curl_easy_setopt(hcurl, CURLOPT_POSTFIELDS, "testcode=123456789");
curl_easy_setopt(hcurl, CURLOPT_WRITEFUNCTION, libcurlWriteMemoryCallback);
curl_easy_setopt(hcurl, CURLOPT_WRITEDATA, (void *)&libcurlchunk);
curl_easy_setopt(hcurl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
This returns "failure"
if I eliminate the CURLOPT_POSTFIELDS option setting changing my c code to:
curl_easy_setopt(hcurl, CURLOPT_URL,
"http://www.mywebsite.com/curltest.php?testcode=123456789");
curl_easy_setopt(hcurl, CURLOPT_WRITEFUNCTION, libcurlWriteMemoryCallback);
curl_easy_setopt(hcurl, CURLOPT_WRITEDATA, (void *)&libcurlchunk);
curl_easy_setopt(hcurl, CURLOPT_USERAGENT, "libcurl-agent/1.0");
it returns "success with testcode = 123456789"
Can anyone tell me what I might be doing wrong ?
Thank You.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-02-05