Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
CURL login form filling
Old 07-09-2009, 12:04 PM CURL login form filling
Junior Talker

Posts: 2
Name: bronski
Trades: 0
I would like to use CURL in order to fill in the username-password form
at the top right of this page http://www.lusa.pt/lusaweb/

I found the variable names in the page's code and tried the curl approach to
no avail (see below)...

Any suggestions ????

Code:
<form action="/lusaweb/dologin" method="post" name="frmLogin">
                <table height="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr><td colspan="2" height="50%"></td></tr>
                    <tr>
                        <td align="right" class="login-text" nowrap="nowrap">&nbsp;&nbsp;Utilizador&nbsp;</td>
                        <td><input type="text" size="9" class="login" name="username" /></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td align="right" class="login-text" nowrap="nowrap">&nbsp;&nbsp;Senha&nbsp;</td>
                        <td><input type="password" size="9" class="login" name="password" /></td>
                        <td>&nbsp;<button type="submit" height="15" style="background-color:#C4201F;border:0"><img border=0 src="/lusaweb/images/go.gif" title="Autenticar"></button></td>
                    </tr>
                    <tr><td colspan="2" height="50%"></td></tr>
                </table>
                </form>
My attempt so far failing:
Code:
$url = "http://www.lusa.pt/lusaweb/"; // This page contains Login form 
  
        $postfields='username=toto&password=titi&action=/lusaweb/dologin'; 
        $ch=curl_init($url); 
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); 
        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); 
        curl_setopt($ch, CURLOPT_POST, 1); 
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); 
        $page=curl_exec($ch); 
         
        curl_close($ch); 
         
        echo $page;

Last edited by devroot; 07-10-2009 at 05:57 AM.. Reason: Removed user's pass
devroot is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-09-2009, 12:37 PM Re: CURL login form filling
Junior Talker

Posts: 2
Name: bronski
Trades: 0
Besides trying to use inside a php prog, I have also tried the following command line
curl http://www.lusa.pt/lusaweb/dologin?u...&password=titi
which returns a html file titled.... <title>An unexpected error occured</title>

Oddly enough, if I type that very same line into my browser, it works great and I log in!
devroot is offline
Reply With Quote
View Public Profile
 
Old 07-10-2009, 11:38 AM Re: CURL login form filling
rezzy's Avatar
Super Talker

Posts: 115
Location: in the interwebz
Trades: 0
It depends on how the site is setup, you might need to establish a user agent. Some sites want to make sure its a browser thats coming to the site and not a php script.

I have also heard others want cookies refrenced, not sure if that helps you on your way.
__________________

Please login or register to view this content. Registration is FREE

Resnodesigns
rezzy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to CURL login form filling
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23258 seconds with 12 queries