cURL / Mailing Lists / curl-users / Single Mail

curl-users

POST results differ on 2 machines

From: Tom Hines <tomhines3_at_gmail.com>
Date: Mon, 11 Jun 2007 23:30:27 -0400

Hello, I'm using php curl on my local machine (winXP), and testing the same
php script at one of my shared hosting accounts (Linux).
It is a post method on a login script, I've been scratching my head for days
and can't seem to find the reason why it will work on one build (Linux -
shared hosting), and not the other (my winXP box).
Any help would be greatly appreciated! Thanks
Here are the results of curl_version() on both machines and the php code
follows:

Local Machine (winXP):
----------------------------------------------------------
[version_number] => 462848
[age] => 2
[features] => 540
[ssl_version_number] => 0
[version] => 7.16.0
[host] => i386-pc-win32
[ssl_version] => OpenSSL/0.9.8e
[libz_version] => 1.2.3
[protocols] => Array
(
[0] => tftp
[1] => ftp
[2] => telnet
[3] => dict
[4] => ldap
[5] => http
[6] => file
[7] => https
[8] => ftps
)

Hosted Machine
----------------------------------------------------------
[version_number] => 462595
[age] => 2
[features] => 1564
[ssl_version_number] => 0
[version] => 7.15.3
[host] => i686-pc-linux-gnu
[ssl_version] => OpenSSL/0.9.7a
[libz_version] => 1.2.3
[protocols] => Array
(
[0] => tftp
[1] => ftp
[2] => telnet
[3] => dict
[4] => ldap
[5] => http
[6] => file
[7] => https
[8] => ftps
)

$url="http://sample.com/login.cgi";
$ref="http://sample.com/";
$post=array('uname'=>'pornofaces', 'pword'=>'pfc1010', 'Submit'=>'Login');
$post=http_build_query($post);
$cookie=tempnam('/tmp','curl');
$agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1)";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_FAILONERROR, true);

curl_setopt($ch, CURLOPT_VERBOSE,1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);

$page = curl_exec($ch);
curl_close($ch);
print $page;
Received on 2007-06-12