uzy Posted August 15, 2009 Share Posted August 15, 2009 Guys, help. Having trouble scripting autologin to this site: http://www.cscsdigitalstorage.com/web/guest/home using cURL. Its form: <form action="http://www.cscsdigitalstorage.com/web/guest/home?p_p_id=58&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=view&saveLastPath=0&_58_struts_action=%2Flogin%2Flogin" class="uni-form" method="post" name="_58_fm"> <input name="_58_redirect" type="hidden" value="" /> <input id="_58_rememberMe" name="_58_rememberMe" type="hidden" value="false" /> <fieldset class="block-labels"> <div class="ctrl-holder"> <label for="_58_login">Email Address</label> <input name="_58_login" type="text" value="[email protected]" /> </div> <div class="ctrl-holder"> <label for="_58_password">Password</label> <input id="_58_password" name="_58_password" type="password" value="" /> <span id="_58_passwordCapsLockSpan" style="display: none;">Caps Lock is on.</span> </div> <div class="ctrl-holder inline-label"> <label for="_58_rememberMeCheckbox">Remember Me</label> <input id="_58_rememberMeCheckbox" type="checkbox" /> </div> <div class="button-holder"> <input type="submit" value="Sign In" /> </div> </fieldset> </form> My code: <?php $crl = curl_init(); $agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'; $url = "http://www.cscsdigitalstorage.com/web/guest/home?p_p_id=58&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=view&saveLastPath=0&_58_struts_action=%2Flogin%2Flogin"; $fp = fopen("cookie.txt", "w"); fclose($fp); curl_setopt($crl, CURLOPT_URL, $url); curl_setopt($crl, CURLOPT_COOKIESESSION, TRUE); curl_setopt($crl, CURLOPT_COOKIEFILE, $fp); curl_setopt($crl, CURLOPT_COOKIEJAR, $fp); curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($crl, CURLOPT_MAXREDIRS, 1); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_POST, 1); curl_setopt ($crl, CURLOPT_USERAGENT, $agent); curl_setopt ($crl, CURLOPT_HEADER, 1); // this array will hold the field names and values $postdata=array( "_58_redirect"=>"", "_58_rememberMe"=>"false", "_58_login"=>"[email protected]", "_58_password"=>"pwd", "_58_rememberMeCheckbox"=>"off", ""=>"Sign In" ); // tell curl we're going to send $postdata as the POST data curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata); $result=curl_exec($crl); $headers = curl_getinfo($crl); print_r($headers); curl_close($crl); if ($headers['url'] == $url) { echo "Cannot login."; } else { echo "Successful"; } ?> --notice that submit button has no name. --I used form action url as cURL url. --do I have more problem than the submit button name? Help guys Link to comment https://forums.phpfreaks.com/topic/170423-auto-login-with-curl-where-submit-button-has-no-name/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.