1

I'm attempting to autologin to https://www.myicomfort.com/ to retrieve data. Tried some of the examples posted but does not seem to work. Maybe I'm not using the correct field names when passing the username and password. Can someone pls help? Still learning PHP. Thanks!

$ch = curl_init();  
curl_setopt($ch, CURLOPT_URL,"https://www.myicomfort.com/");  
curl_setopt($ch, CURLOPT_COOKIEFILE,1);  
curl_setopt($ch, CURLOPT_POST, 1);  
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);  
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
curl_setopt($ch, CURLOPT_HEADER, true);    
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);  
curl_setopt($ch, CURLOPT_TIMEOUT, 120);  

$post_array = array(  
'ctl00$RightContent$txtUserName'=>'xxxname',  
'ctl00$RightContent$txtPwd'=>'xxxpassword',  
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 

$output = curl_exec($ch);

curl_close($ch);

`

  • I checked your website and there are a lot of hidden fields in the form, make sure you send them too – Hugo Dozois Sep 16 '12 at 19:56
  • I think this help you : http://stackoverflow.com/questions/20049393/using-php-curl-to-login-to-my-websites-form –  May 24 '14 at 06:19

3 Answers3

1

You are missing the other fields. You can check which fields are being sent by pressing Ctrl+Shift+I in Chrome, then try to login. Click on the page and you will see something like this:

__LASTFOCUS:
__EVENTTARGET:
__EVENTARGUMENT:
__VIEWSTATE:/wEPDwUKMTczNjcxMDc0Mg9kFgJmD2QWAgIDD2QWBAIDD2QWBAI...
__EVENTVALIDATION:/wEWCAKI/qyXDAKSptf/CwKJn6v3AQKdg7/fBwKNoqOVDAK...
ctl00$RightContent$hdnPwd:
ctl00$RightContent$txtUserName:asfasdfa
ctl00$RightContent$txtPwd:dfasdf
ctl00$RightContent$chkRemember:on
ctl00$RightContent$btnLogin:Log in

Try to submit those data too. Once you've done this, you should be able to login.

rationalboss
  • 5,330
  • 3
  • 30
  • 50
  • Thanks for quick feedback. I tried that too but no luck. When I echo the $output, am I supposed to see the values passed as username and password? Source page when successful login shows : – user1676114 Sep 16 '12 at 19:49
  • Thanks for the Chrome tip. There are a lot of info on the page. For future reference, which tab shld I choose to look for these hidden fields once the tool comes up? – user1676114 Sep 16 '12 at 20:14
0

Make sure you are using all the input fields required, doing a net sniff on information being transmitted from the form results in this

'__EVENTARGUMENT'   
'__EVENTTARGET' 
'__EVENTVALIDATION'             /wEWCAKI/qyXDAKSptf/CwKJng .. etc
'__LASTFOCUS'   
'__VIEWSTATE'                   /wEPDwUKMTczNjcxMDc0Mg9kFgJmD2QWAg .. etc
'ctl00$RightContent$btnLog...'  Log in
'ctl00$RightContent$chkRem...'  on
'ctl00$RightContent$hdnPwd' 
'ctl00$RightContent$txtPwd'     vyvuy
'ctl00$RightContent$txtUse...'  iuhgiu

See also this question on SO where I believe they suggested to at a missing login button

Community
  • 1
  • 1
dbf
  • 3,278
  • 1
  • 24
  • 34
0

U can look into the source code of that page, there are many hidden input fields. Just provide your username and password is not enough.

Solutions:

  1. get all these fields and send them out together using PHP
  2. use some library which can simulate browser, then u can only provide username and password when logging in. This would be a little slow, but NOT the bottleneck of your code.
alsotang
  • 1,520
  • 1
  • 13
  • 15