cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: problem using curk with posting passwords

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 21 May 2003 09:11:27 +0200 (CEST)

On Tue, 20 May 2003, Z. Rashid wrote:

> My problem is best understood if you take a look at the site
> http://www.advfn.com/p.php?pid=news

[html page with login form]

> I tries to post the fields but a problem ocurrs I think this is because the
> second textbox is a password box

The types of the boxes are only valid for the browser and how it displays
them on screen, not how they are sent in HTTP.

> (as when I dump what curl retrieved I see
> that the username text bok IS filled but the password text box is empty)
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_POSTFIELDS, "username=zrashid_&password=ycdgbhud");
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

You've forgot a lot of hidden fields. I ran 'formfind' on the web page you
pointed out and it finds these fields:

Input: 'btn'='' ('HIDDEN')
Input: 'pid'='news' ('HIDDEN')
Input: 'lb_q'='pid=news' ('HIDDEN')
Input: 'lb_un'='' ('TEXT')
Input: 'lb_pw'='' ('PASSWORD')
Input: 'lb_sub'=lb_sub ('SUBMIT')
Input: 'lb_save'='1' ('CHECKBOX')
Input: 'symbol'='' ('HIDDEN')

> There are cookies that are involved (there is a log in automatically
> tickbox) but there are multiple ones saved on the disk from the advfn
> wesbite and I dont know how to formulate them. I tried curl_setopt($ch,
> CURLOPT_COOKIE, "filename in same directory as script"); but this did not
> work either.

I'd recommend you to first read the cookie chapter in this:

        http://curl.haxx.se/libcurl/c/the-guide.html

> My question is is there a way of passing multiple cookies

COOKIEJAR is probably what you're looking for.

> and is there a way of sending the post as a password and accepting the
> ensuing cookie (and keep using it as the news site will be accessed every
> 15 minutes for the whole day)

Yes, use the jar and send the request whenever you want.

-- 
 Daniel Stenberg -- curl: been grokking URLs since 1998
-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
Received on 2003-05-21