cURL / Mailing Lists / curl-users / Single Mail

curl-users

RE: POSTing a form...

From: Mark C. Casey <markcc_at_jadepress.co.uk>
Date: Wed, 9 Mar 2005 14:11:41 -0000

Okay...

I seem to have provisionally got it working...

If I use the following it seems to work...

curl -d "SITE_ID=22&LOGIN_ID=username&USR_LOGIN_PSWD=password&lang=DEFAULT" https://site.domain.tld/test/Login.jsp -v -k -c cookies.txt

Followed by...

curl -k -b cookies.txt https://site.domain.tld/test/dsk_mydesktop_sup.jsp -o filename.html

Hopefully it'll hold up to more thorough testing...

Mark

-----Original Message-----
From: curl-users-bounces_at_cool.haxx.se
[mailto:curl-users-bounces_at_cool.haxx.se]On Behalf Of Mark C. Casey
Sent: 09 March 2005 11:47
To: curl-users_at_cool.haxx.se
Subject: POSTing a form...

Okay, here's the chopped up source for a form i'm trying to submit...

(Javascript bit is in the <head></head>, I apologise for the length of this btw)

<script language="JavaScript">
<!--

var reg = /\W/;

function callSubmit()
{
        var username = document.frmLogin.LOGIN_ID.value;
        var password = document.frmLogin.USR_LOGIN_PSWD.value;
    if(username == "" || reg.test(username))
    {
        alert('Please enter valid Login name');
        document.frmLogin.LOGIN_ID.value = "";
        document.frmLogin.LOGIN_ID.focus();
    }
    else if(password == "")
    {
        alert('Please enter Password');
        document.frmLogin.USR_LOGIN_PSWD.focus();
    }
    else
    {
        document.frmLogin.LOGIN_ID.value = username.toLowerCase();
        document.frmLogin.USR_LOGIN_PSWD.value = password.toLowerCase();
        document.frmLogin.submit();
    }
}

// -->
</script>

<FORM NAME="frmLogin" ACTION="Login.jsp" METHOD="POST">
        <input type="hidden" name="SITE_ID" value="22">
        <input type="text" name="LOGIN_ID">
        <input type="password" name="USR_LOGIN_PSWD">
        <select name="lang">
                <option value="DEFAULT" SELECTED>Default</option>
                <option value="GB">English</option>
                <option value="FR">French</option>
                <option value="DE">German</option>
                <option value="IT">Italian</option>
                <option value="ES">Spanish</option>
        </select>
        <a href="javascript:callSubmit()">&nbsp;Enter Site&nbsp;</a>
</form>

>From what I can tell I have four fields that need submitting, 'SITE_ID', 'LOGIN_ID', 'USR_LOGIN_PSWD' and 'lang'.

I've been using the command:

curl -d "SITE_ID=22&LOGIN_ID=username&USR_LOGIN_PSWD=password&lang=DEFAULT" https://site.domain.tld/test/Login.jsp -v -o test4.htm -k -L -c cookies.txt -A 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)'

It saves a sessionid in the file cookies.txt.

But it still saves same login page as test4.htm instead of going to any next page (and saving that).

So, I try the following with the saved sessionid cookie:

curl -vo testnew.htm https://site.domain.tld/test/dsk_mydesktop_sup.jsp -b cookies.txt -k

However, this gives me an error message (in the html from the site)... If I copy the sessionid content (from the cookies.txt file) itself over an already existing sessionid (that works) under firefox and go to the login page it tells me that the login failed.

Anybody have any idea what I might be doing wrong?

Thanks

Mark Casey
IT Manager
Jade Press
Received on 2005-03-09