Jump to content

Recommended Posts

Hi,

 

I've asked to automate the login process of the http://reboot.pro forum. The login form is available at http://reboot.pro/index.php?app=core&module=global&section=login. The HTML form shown below can be used to login to the forum:

 

 
<html>
<form action="http://reboot.pro/index.php?app=core&module=global&section=login&do=process" method="post" id='logon'>
  <input type='hidden' name='auth_key' value='880ea6a14ea49e853634fbdc5015a024' />    
  <input type='text' name='username' />
  <input type='password' name='password' />
  <input type='submit' value='Sign In' />
</form>
</html>

 

To simulate the login process from the PHP code, I've written the script:

<?php
//create array of data to be posted
$post_data['auth_key'] = '880ea6a14ea49e853634fbdc5015a024';
$post_data['username'] = 'testaccount';
$post_data['password'] = 'testaccount';

//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
    $post_items[] = $key . '=' . $value;
}

//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
echo $post_string;

//create cURL connection
$curl_connection = curl_init('http://reboot.pro/index.php?app=core&module=global&section=login&do=process');

//set options
curl_setopt($curl_connection, CURLOPT_POST, true);
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);

//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);

//perform our request
$result = curl_exec($curl_connection);echo $result;

//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' . curl_error($curl_connection);

//close the connection
curl_close($curl_connection);

?>

 

But, in effect, login process is not triggered but the forum homepage, i.e. which is presented to Guest users, appears. Can anubody plese help me in fixing this or point me out where am I doing wrong?

 

Note: I'm using EasyPHP (latest stable version) with cURL extension enabled.

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/244311-problem-with-curl-library/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.