lihman Posted August 31, 2009 Share Posted August 31, 2009 I am trying to use cURL to log in to a website. However, the submit button is not a regular form submit. Here is the code of the website login form: <body onLoad="document.login.email_address.focus();"><div id="page"> <div id="header"> <h1><a href="/">Website Title</a></h1> <div class="min_width_buffer"></div> <form action="/user/login" method="post" name="login"> <div>Email: <input type="text" id="email_address" name="user[email]" class="text" /></div> <div>Password: <input type="password" name="user[password]" class="text" /></div> <input type="image" class="submitbtn" src="/templates/new_notlogged/submitbtn.gif" /> <span id="login_messages"><a href="/user/forgot_password">Forgot Password?</a></span> </form> This is my php code so far: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt"); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_URL, 'http://domain.com/user/login'); curl_setopt($ch, CURLOPT_POSTFIELDS, 'user[email][email protected]&password=mypass'); $result1 = curl_exec($ch); #and then make a temp copy $ch_temp=curl_copy_handle($ch); curl_close($ch); $ch=$ch_temp; ?> The problem is that I do not know how to submit to the form since a regular &submit=TRUE or something won't work. Link to comment https://forums.phpfreaks.com/topic/172583-php-curl-login-problem/ Share on other sites More sharing options...
Garethp Posted August 31, 2009 Share Posted August 31, 2009 It looks like your normal form to me. If your worried about how it is, use this with firefox https://addons.mozilla.org/en-US/firefox/addon/966 It'll show you all the data you need to know Link to comment https://forums.phpfreaks.com/topic/172583-php-curl-login-problem/#findComment-909758 Share on other sites More sharing options...
lihman Posted August 31, 2009 Author Share Posted August 31, 2009 Thanks, I used TamperData and it worked Link to comment https://forums.phpfreaks.com/topic/172583-php-curl-login-problem/#findComment-909763 Share on other sites More sharing options...
lihman Posted August 31, 2009 Author Share Posted August 31, 2009 I've just encountered another problem and I am not sure TamperData will work this time. I need php cURL to click a button repeatedly but the button has nothing to do with a form, it is all javascript. <script type="text/javascript"> function set_opacity(id, opacity) { element = document.getElementById(id) if (/MSIE/i.test(navigator.userAgent)) { element.style.filter='alpha(opacity='+opacity+')'; } else { element.style.opacity = opacity/100; } } </script> <table cellspacing="0" width="100%"> <tr> <td class="center"> <h4 class="strong"> 1 / 375 clicked today </h4> <p> <script type="text/javascript"> //<![CDATA[ recruiter_clicks = 1 //]]> </script><a href="/recruiter/recruit/28cs5n4qu339k" id="recruit_link" onclick="return(submit_link_as_post_with_opacity(this, 'recruit_image'))"><img alt="" class="btn button_recruit" id="recruit_image" src="/A.gif?1221518016" /></a><script type="text/javascript"> //<![CDATA[ link = document.getElementById('recruit_link'); link_href = link.href; link.href = "#"; set_opacity('recruit_image', 50); setTimeout("link = document.getElementById('recruit_link'); link.href = '" + link_href + "'; recruiter_clicks = 0; set_opacity('recruit_image', 100)", 2000); //]]> </script> </p> According to TamperData, the POSTDATA for every click is: POSTDATA=Content-Type: application/x-www-form-urlencoded Content-Length: 0 Any help? Link to comment https://forums.phpfreaks.com/topic/172583-php-curl-login-problem/#findComment-909767 Share on other sites More sharing options...
lihman Posted August 31, 2009 Author Share Posted August 31, 2009 Anybody? please? Link to comment https://forums.phpfreaks.com/topic/172583-php-curl-login-problem/#findComment-909885 Share on other sites More sharing options...
Garethp Posted August 31, 2009 Share Posted August 31, 2009 Curl is a method of form submission. From what I know, it doesn't do javascript. Look it up in PHP.net though Link to comment https://forums.phpfreaks.com/topic/172583-php-curl-login-problem/#findComment-909886 Share on other sites More sharing options...
lihman Posted August 31, 2009 Author Share Posted August 31, 2009 Thanks for the help I guess. I've looked around and couldn't find anything. Is there any way at all to submit that button in the code above that anybody knows about? Like incorporating some javascript into the php file? Link to comment https://forums.phpfreaks.com/topic/172583-php-curl-login-problem/#findComment-909895 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.