Jump to content

automatic login to website


yesh

Recommended Posts

Hello ,

I'm here with a problem facing with automatic login , I'm not able to login programmatically and fill the forms programatically to other website . here is the code which i have tried .

 

<?php
    
    
 
 
$ch=curl_init();
 
 
$headers = array(
    'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 
    'Accept-Encoding: gzip,deflate,sdch', 
    'Accept-Language: en-GB,en-US;q=0.8,en;q=0.6',
    'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36' 
);
 
$cookie='/cookie.txt';
$curl_data = "Login1\$UserName=abc&Login1\$Password=123";
//&__VIEWSTATE=>/wEPDwUJMzE2NDc5ODU3ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAgURTG9naW4xJFJlbWVtYmVyTWUFF0xvZ2luMSRMb2dpbkltYWdlQnV0dG9ukK3V3IzBCYqop9/bJLrN4/gCDUo=';
 
//var_dump($curl_data);
 
$options = array( 
        CURLOPT_RETURNTRANSFER => true,         // return web page 
        CURLOPT_HEADER         => false,        // don't return headers 
        CURLOPT_FOLLOWLOCATION => true,         // follow redirects 
        CURLOPT_ENCODING       => "",           // handle all encodings 
        CURLOPT_USERAGENT      => "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36",     // who am i 
        CURLOPT_AUTOREFERER    => true,         // set referer on redirect 
        CURLOPT_CONNECTTIMEOUT => 120,          // timeout on connect 
        CURLOPT_TIMEOUT        => 120,          // timeout on response 
        CURLOPT_MAXREDIRS      => 10,           // stop after 10 redirects 
        CURLOPT_POST            => 1,            // i am sending post data 
        CURLOPT_SSL_VERIFYHOST => 0,            // don't verify ssl 
        CURLOPT_SSL_VERIFYPEER => false,        // 
        CURLOPT_VERBOSE        => 1,            // 
        CURLOPT_HTTPAUTH => CURLAUTH_ANY,
        CURLOPT_SSL_VERIFYHOST => false,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_POST => 1,
        CURLOPT_COOKIESESSION => TRUE,
    CURLOPT_COOKIEJAR => $cookie ,
        CURLOPT_HTTPHEADER =>  $headers,
        CURLOPT_URL => $url,    
        CURLOPT_POSTFIELDS     => $curl_data ,   // this are my post var
        
       ); 
 
 
curl_setopt_array($ch,$options); 
 
// executimng the curl and storing it in the variable 
$store = curl_exec ($ch);
 
// provides with web page 
echo $store;
//print $store;
 
// closing of curl initiation 
curl_close ($ch);
 
        
?>
and output i get will be like user login page :( 
Link to comment
https://forums.phpfreaks.com/topic/292065-automatic-login-to-website/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.