i have a small problem understanding how to transform this jquery code in php , i want to use curl to remote login to a website. $.ajax({type:'POST',url:'/',data:{action:'login',username:$('#login_username').val(),remember:$('#login_remember').is(':checked')?'1':'0',PAS5WORD:hex_md5($('#login_password').val()+hex_md5($('#login_username').val())+' + '+$('#login_nonce').val()+' + '),PAS5W0RD:hex_md5($('#login_password').val()+' + '+hex_md5($('#login_username').val()+' + '+$('#login_nonce').val())),PA55WORD:hex_md5(' + '+hex_md5($('#login_nonce').val()+$('#login_username').val())+' + '+$('#login_password').val()),PASSW0RD:hex_md5(hex_md5($('#login_password').val())+' + '+$('#login_nonce').val()+' + '+$('#login_username').val()),PA5SW0RD:hex_md5(hex_md5(' + '+$('#login_username').val()+$('#login_password').val())+' + '+$('#login_nonce').val()),PA5SWORD:hex_md5($('#login_username').val()+' + '+hex_md5($('#login_nonce').val()+' + '+$('#login_password').val())),PA55W0RD:hex_md5($('#login_nonce').val()+hex_md5(' + '+$('#login_password').val()+$('#login_username').val()+' + ')),PASSWORD:$('#login_nonce').val(),force_login:$('#force_login').val(),retrimite_email:$('#retrimite_email').val()},success:function(html){if(html=='ok'){$('#login_error').html('') Code (markup): Tanks . if u can help me please pm me or replay here . tanks
hi, u can use this code to make a curl request : function NewRequest($user,$pass) { $postfields = "login_username=".$user."&password=".md5($pass); $url = "http://yourdomain.com/loginscript.php"; $headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; $headers[] = 'Connection: Keep-Alive'; $headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.16) Gecko/20101130 Firefox/3.5.16 GTB7.1 SearchToolbar/1.2'); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_REFERER, $refer); $cont = curl_exec($ch); return $cont; } $login = NewRequest($user,$pass); $login trim($login); if ($login=="1") { echo "Logged in";} else { echo $login;} Code (markup): The file loginscript.php must accept the post command and return only the value 1 if user information is correct and return some other text in other cases, that could be error login msg or else. Hope this helps.