Can a PHP script log into a public site with username/pass?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
doncoglioni
Forum Newbie
Posts: 2
Joined: Thu Mar 20, 2008 8:08 pm

Can a PHP script log into a public site with username/pass?

Post by doncoglioni »

Hi all! :)

I have a script which analyses HTML documents and summarises some information for them, related to my work. The script itself works fine, if I have access to the HTML pages concerned. However, most of the ones I need are only accessible when I log in to a (public) website with a username and password field.

So my question is this: can a PHP script automatically "enter" the username and password, and log into the website, then (remaining authenticated for that session) fetch the protected pages that I need, just as if a human was sitting doing the same thing? No captchas are involved. Obviously I would need some information regarding the target page's username/password form and method of submission... but how would I go about doing this, generally?

My sincere thanks for any help.
hayson1991
Forum Newbie
Posts: 14
Joined: Thu Mar 20, 2008 1:19 pm

Re: Can a PHP script log into a public site with username/pass?

Post by hayson1991 »

doncoglioni wrote:Hi all! :)

I have a script which analyses HTML documents and summarises some information for them, related to my work. The script itself works fine, if I have access to the HTML pages concerned. However, most of the ones I need are only accessible when I log in to a (public) website with a username and password field.

So my question is this: can a PHP script automatically "enter" the username and password, and log into the website, then (remaining authenticated for that session) fetch the protected pages that I need, just as if a human was sitting doing the same thing? No captchas are involved. Obviously I would need some information regarding the target page's username/password form and method of submission... but how would I go about doing this, generally?

My sincere thanks for any help.
I've been wondering about that too.
doncoglioni
Forum Newbie
Posts: 2
Joined: Thu Mar 20, 2008 8:08 pm

Re: Can a PHP script log into a public site with username/pass?

Post by doncoglioni »

hayson1991 wrote:I've been wondering about that too.
I found this, it might be what I'm looking for. But any suggestions, please let me know:
http://www.wagerank.com/2007/how-to-sub ... -with-php/
mVeliki
Forum Newbie
Posts: 8
Joined: Mon Mar 17, 2008 4:42 pm

Re: Can a PHP script log into a public site with username/pass?

Post by mVeliki »

Use CURL.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: Can a PHP script log into a public site with username/pass?

Post by Oren »

Of course PHP can. What's the difference between a normal user who sends POST/GET data and a PHP script which does the same?
Post Reply