473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

CURLOPT_POST ... doesn't!

(Environment: Linux)
curl 7.10.6 (i386-redhat-linux-gnu) libcurl/7.10.6 OpenSSL/0.9.7a ipv6
zlib/1.1.4
Protocols: ftp gopher telnet dict ldap http file https ftps
Features: IPv6 SSL libz NTLM
==
PHP 5.0.2 (cgi) (built: Jul 10 2005 15:41:02)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.2, Copyright (c) 1998-2004 Zend Technologies
==

I can use CURL to retrieve a web-page but when I try to use POST, it
doesn't seem to actually post anything. The code is:

++++++++++++++++++++++++++++++++++++++++++++
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, True);
curl_setopt ($ch, CURLOPT_USERAGENT, $config['user_agent']);
curl_setopt ($ch, CURLOPT_HEADER, True);
curl_setopt ($ch, CURLOPT_VERBOSE, True);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, True);
global $errfile;
curl_setopt ($ch, CURLOPT_STDERR, $errfile);
curl_setopt ($ch, CURLOPT_FAILONERROR, True);
// If we have any cookies, send them with each request.
if (retrieve_cookies($cook))
curl_setopt($ch, CURLOPT_COOKIE, $cook);
// If the caller provided any POST variables, send them... properly
formatted.
if (!empty($postvars)) {
if (is_array($postvars)) {
$post = '';
$amper = '';
foreach ($postvars as $p=>$v) {
$post .= $amper . urlencode($p) . '=' . urlencode($v);
$amper = '&';
}
} else $post = $postvars;
echo ">>Sending POST vars: '$post'\n";
// e.g. "username=goofus&password=gallant"
curl_setopt ($ch, CURL_POST, True);
curl_setopt ($ch, CURL_POSTFIELDS, $post);
}
$data = curl_exec($ch);

Script debugging output confirms that "$post" does have a
properly-formatted string in it, e.g.
"username=goofus&password=gallant" And that CURL_POSTFIELDS is indeed
being called. But I see no indication that this data is making it to
the server.

The (sanitized...) VERBOSE logfile is:
=================================
* About to connect() to xxx.yyy.com:80
* Connected to aaa.bbb.net (11.22.33.44) port 80
GET /index.cgi HTTP/1.1

User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
Host: xxx.yyy.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*

< HTTP/1.1 200 OK
< Date: ...
< Server: Apache ...
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/html
* Closing connection #0
==================================

Jul 17 '05 #1
2 6426
Rather than $post being a string, try making it an array:

$post = array('username' => 'goofus', 'password' => 'gallant')

Jul 17 '05 #2
Okay, I tried that, and unfortunately it had no effect.

Also... just to make sure, I retrieved the latest source-code, compiled
it from source, re-built PHP the same way (confirming that PHP does
reference the new library via 'php --info')... nothing changed.
==
curl 7.14.0 (i686-pc-linux-gnu) libcurl/7.14.0 OpenSSL/0.9.7a
zlib/1.1.4
Protocols: ftp gopher telnet dict ldap http file https ftps
Features: Largefile NTLM SSL libz
==

I don't know how to easily tell /exactly/ what the two systems are
saying to each other (in the Linux environment), although I suppose
that will be the next step. (Anyone tell me how that's done?)

I'm not enough of an HTTP-guru to be able to tell whether the verbose
logfile (from the original post) does, or does not, tell me if the
post-data is being sent.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
39
by: Mark Johnson | last post by:
It doesn't seem possible. But would the following also seem a violation of the general notions behind css? You have a DIV, say asociated with class, 'topdiv'. Inside of that you have an anchor...
4
by: Bob Bedford | last post by:
We have no access to a mysql NG on my provider's server, so we ask here: We have a long query (long in text) with a UNION between 2 select. We have been informed that some times the query...
149
by: Christopher Benson-Manica | last post by:
(Followups set to comp.std.c. Apologies if the crosspost is unwelcome.) strchr() is to strrchr() as strstr() is to strrstr(), but strrstr() isn't part of the standard. Why not? --...
43
by: Zeng | last post by:
It's so messy w/o the "friend" relationship. Does anyone know why it was not supported in C#. It's almost about as bad as it doesn't support the inheritance hierarchy and method reference...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
1
by: jmilane | last post by:
Hi, I am trying to use curlop_post to post $_POST to another server that does not have a public IP. I have the form pass all its data to an intermediary file that contains this code: $ch =...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
38
by: tshad | last post by:
In VS 2008, why doesn't ToString require "()". If I have Option Strict On on why can I do both: selectedIndex.ToString() selectedIndex.ToString or sQuery =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.