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);

`

2
  • I checked your website and there are a lot of hidden fields in the form, make sure you send them too Commented Sep 16, 2012 at 19:56
  • I think this help you : stackoverflow.com/questions/20049393/… Commented May 24, 2014 at 6:19

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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 : <input name="ctl00$RightContent$txtUserName" type="text" value="xxxname" id="RightContent_txtUserName" /> <label for="password">Password<br/> <input name="ctl00$RightContent$txtPwd" type="password" id="RightContent_txtPwd" value="xxxpassword" /> </label>
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?
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

1 Comment

THANK YOU!!! It works now. I didnt think I needed to add all the hidden fields on the form.
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.