php - login using curl not working with captcha -


i trying home page after login using curl don't know why not displayed. think wrong in code; please check code , let me know whats wrong in code

i tried every thing fails every time seen possible login in website, have 1 software login trial version , wanted build same thing in php

<?php  $file_contents=file_get_contents("https://www.irctc.co.in/eticketing/loginhome.jsf"); $dom = new domdocument(); @$dom->loadhtml($file_contents);  $xpath = new domxpath($dom); $imgs = $xpath->query('//*[@id="cimage"]'); foreach($imgs $img) {     $imagesrc=$img->getattribute('src') . php_eol; } ?>  <?php //initial request login data if(isset($_request['submit'])) {       $user='ansari4all';       $pass='ansari4all';       $captcha=$_request['j_captcha'];       $submit=$_request['submit'];       $ch = curl_init();        curl_setopt($ch, curlopt_url, 'https://www.irctc.co.in/eticketing/loginhome.jsf');       curl_setopt($ch, curlopt_useragent,'mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) ubuntu chromium/32.0.1700.107 chrome/32.0.1700.107 safari/537.36');       curl_setopt($ch, curlopt_post, true);       curl_setopt($ch, curlopt_postfields, "j_username=$user&j_password=$pass&j_captcha=$captcha&submit=$submit");       curl_setopt($ch, curlopt_returntransfer, true);       curl_setopt($ch, curlopt_cookiesession, true);       curl_setopt($ch, curlopt_ssl_verifypeer, false);       curl_setopt($ch, curlopt_cookiejar, 'cookie-name');  //could empty, cause problems on hosts       curl_setopt($ch, curlopt_cookiefile, '/var/www/ip4.x/file/tmp');  //could empty, cause problems on hosts       $answer = curl_exec($ch);       if (curl_error($ch)) {           echo curl_error($ch);       }        //another request preserving session        curl_setopt($ch, curlopt_url, 'https://www.irctc.co.in/eticketing/home');       curl_setopt($ch, curlopt_post, false);       curl_setopt($ch, curlopt_postfields, "");       echo $answer = curl_exec($ch);       if (curl_error($ch)) {           echo curl_error($ch);       } } ?> <form method="post">     <img src="https://www.irctc.co.in/eticketing/<?php echo $imagesrc;?>" />     captcha:<input type="text" name="j_captcha" />     <input id="loginbutton" type="submit" name="submit" value="login"  />    </form> 

i cannot login site browser, everytime says

enter image description here

seems error of page. if not, should image url , image curl , use session post request. important captchas.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -