CURL problems posting data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ave,

We need to login to a client¹s website in order to feed some data to their
database, using their forms. To automate it, I¹m trying to use Curl to
login. 

This is their form:
<form name="Form1" method="post" action="http://www.website.com/Login.aspx";
id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwtNDI5NDcwNDM2Ozs+oeS6YcaxMhbb66r8w2jsMzFiezM=" />
<input name="login:username" VALUE="usr" type="HIDDEN" id="login_username"
/>
<input name="login:password" VALUE="pwd" type="HIDDEN" id="login_password"
/>
<input name="login:txtAffiliateCode" VALUE="db" type="HIDDEN"
id="login_txtAffiliateCode" />
<input type="submit" name="login:loginbutton" value="Login"
id="login_loginbutton">
</form>

I¹m not quite sure why their field names have a ³:² and what purpose it
serves, but I just can¹t seem to login using Curl no matter what I try. I¹ve
gone through testing different codes, and this is where I¹m at to make this
work:

<?php 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.website.com/Login.aspx";);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
urlencode('login:username')."=usr&".urlencode('login:password')."=pwd&".urle
ncode('login:txtAffiliateCode')."=db&".urlencode('__VIEWSTATE')."=".urlencod
e('dDwtNDI5NDcwNDM2Ozs+oeS6YcaxMhbb66r8w2jsMzFiezM='));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec ($ch);
if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close ($ch);
print_r($result);
?>

Needless to say that if I put their form ³as-is² on a page on my server and
specify full URL in ³ACTION², it works.
Why is Curl failing to log me in?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: sleepwalker@xxxxxxxxxxxxxxxx

³I morti non sono piu soli ... The dead are no longer lonely²


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux