10

I am trying to login to the website www.centralgreen.com.sg/login.php using cURL (first time user of cURL)

I used the Tamper plugin for Firefox, and I have 4 POST inputs:

login=mylogin
password=mypassword
Button_DoLogin.x=33
Button_DoLogin.y=6

I tried to use curl again using

curl.exe --data 'login=mylogin&password=mypassword&Button_DoLogin.x=33&Button_DoLogin.y=6' www.centralgreen.com.sg/login.php?ccsForm=Login

But the login apparently doesn't go through (the output of this command is the same form, filled with only the password, and an error message The value in field Username is required.)

Here is the full list of info I get from Tamper

Host centralgreen.com.sg
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept Language en-us,en;q=0.5
Accept Encoding gzip, deflate
Accept Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep Alive 115
Connection keep-alive
Referer http://centralgreen.com.sg/login.php
Cookie PHPSESSID=65fbxxxxxxx02694e3a72xxxxxxxx; Valley_ParkLogin=04E203A459FCxxxxxxxA2DCD9AAE5B9678G08C04F1952155E2482xxxxxxxxxxxxx

Is there anything I do wrong? How can I pass the login through the POST form?

Ram Sharma
  • 8,676
  • 7
  • 43
  • 56
RockScience
  • 17,932
  • 26
  • 89
  • 125

1 Answers1

9

Try using the -F option instead of --data.

http://curl.haxx.se/docs/manpage.html#-F

Basically, this changes the content type header to:

Content-Type: multipart/form-data

This may give you a better result.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • Could you advice on how to use it? I have tried with no success curl.exe --form 'login=mylogin;password=mypassord;Button_DoLogin.x=10;Button_DoLogin.y=8' www.centralgreen.com.sg/login.php?ccsForm=Login – RockScience Jul 18 '11 at 04:12
  • same for curl.exe -F 'login=mylogin' -F 'password=mypassword' www.centralgreen.com.sg/login.php?ccsForm=Login – RockScience Jul 18 '11 at 04:21
  • Hmm, that isn't the problem then. Can you post the full HTTP headers for both sides using the form **and** cURL, so we can see the differences? – Brad Jul 18 '11 at 13:46
  • Thank you for your help, may I ask you how I do that (I am relatively new to cURL so I am not familiar with some terms) – RockScience Jul 19 '11 at 02:37
  • Use a packet sniffer such as Wireshark, or a proxy such as Fiddler. – Brad Jul 19 '11 at 02:40
  • Note that it is uppercase F, lowercase corresponds to --fail – Masse Mar 27 '13 at 11:01
  • Fixed. Thanks for catching that! – Brad Mar 27 '13 at 13:49