Jump to content

PHP cURL Login Problem


lihman

Recommended Posts

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

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? :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.