yesh Posted October 26, 2014 Share Posted October 26, 2014 (edited) 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 $url="http://gis.lntecc.com/bwssblnt/Scada.aspx?field1=Kathriguppe%2cSW2DM0402%2c235505H073%2c450"; $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 Edited October 26, 2014 by yesh Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.