what is wrong with my multi log in code ?plz help.

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

shiva
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Jun 03, 2013 10:02 am
Location: india

what is wrong with my multi log in code ?plz help.

Postby shiva » Mon Jun 03, 2013 10:17 am

i want to log in in by curl on a site with 2 deffrent username n pass using wheel loop ..........but oly 1 user(shiva) loged 2 times ...randome log in not working<somthing wrong with array>...plz help me to fix.....plz note url and user pass is not orginal......its only example....

Code: Select all

<?php
include("top.php");
?><?php
echo "<title>xxxxxxxxxx</title>";
?>
<?php

      $users = array(
    'dertu' => '8878513333',
    'shiva' => '8878566666',
    // etc.
);
 
foreach($users as $username => $password)
{
    //Execute same block of code for each username/password
}
$i = 0;
while($i != 2) {
      $tomob ="9993264376";
  $c = $_REQUEST['recaptcha_challenge_field'];
      $cv = $_REQUEST['recaptcha_response_field'];
    $cookie = tempnam("/coki", "CURLCOOKIE");
      $ch = curl_init();
      curl_setopt($ch,CURLOPT_URL,"http://example.com/login.php");

      curl_setopt($ch,CURLOPT_COOKIEJAR,$cookie);
      curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch,CURLOPT_REFERER,"ttp://example.com/login.php");
               $one=curl_exec($ch);

      preg_match("/input name=\"(.*?)\" type=\"text\" class=\"existing_user round_four\" id=/i",$one,$matches);
      $user = $matches[1];

      preg_match("/input name=\"(.*?)\" type=\"password\" class=\"existing_user round_four\" id=/i",$one,$matches);
      $pass = $matches[1];
 $post_data = "$user=$username&$pass=$password&RememberMe=1&submit2=LOGIN HERE";
   $url = "http://example.com/login.php";
    $cookie = tempnam("/coki", "CURLCOOKIE");
   $ch = curl_init();
   curl_setopt( $ch, CURLOPT_USERAGENT,"User-Agent: Mozilla/7.0 (Windows NT 6.1; rv:10.0) Gecko/20100101 Firefox/9.0" );
   curl_setopt( $ch, CURLOPT_URL, $url );
   curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
   curl_setopt($ch, CURLOPT_POST, true);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
   curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie );
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
   curl_setopt( $ch, CURLOPT_AUTOREFERER, true );

   $ct = curl_exec( $ch );


if(stristr($ct,"number & password"))
{
echo "<font color='red'><b>Invalid mobile number / password. Try Again With Correct Details.</b></font>";
}
else
{

if(stristr($ct,"dfhg.php"))
{
$post_data2 = "recaptcha_challenge_field=$c&recaptcha_response_field=$cv";
   curl_setopt($ch, CURLOPT_URL,"http://example.com/upd.php");   
   curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded","Accept: */*"));
   curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data2);
   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_REFERER, "http://example.com/login.php");
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         
   $dt = curl_exec($ch);
}
$i++;
}
?>
Last edited by shiva on Wed Jun 05, 2013 7:31 am, edited 10 times in total.

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: what is wrong with my multi log in code ?plz help.

Postby johnj » Tue Jun 04, 2013 1:05 am

This is the condition that you have set - if(stristr($ct,"number & password")). Check why this condition is getting true and hence the error message.

shiva
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Jun 03, 2013 10:02 am
Location: india

Re: what is wrong with my multi log in code ?plz help.

Postby shiva » Wed Jun 05, 2013 3:16 am

johnj wrote:This is the condition that you have set - if(stristr($ct,"number & password")). Check why this condition is getting true and hence the error message.





i am newbi on php so unabale to fix after a lot of try.........

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: what is wrong with my multi log in code ?plz help.

Postby johnj » Wed Jun 05, 2013 6:34 am

please print $ct and see if "number & password " is there.

shiva
New php-forum User
New php-forum User
Posts: 3
Joined: Mon Jun 03, 2013 10:02 am
Location: india

Re: what is wrong with my multi log in code ?plz help.

Postby shiva » Wed Jun 05, 2013 7:17 am

johnj wrote:please print $ct and see if "number & password " is there.




now result has changed.........but 1 user called shiva loged 2 time..user not switiching......plz help with aaray.........plz ote url and user pass is not orginal......its only example....


Return to “PHP coding => General”

Who is online

Users browsing this forum: Baidu [Spider] and 6 guests