Jump to content

Turn Hardcode into Database Run


Russia

Recommended Posts

I currently have this code, its an account checker for a website, it checks if the information is valid or not.

 

<?php
$username = "username";
$password = "password";

   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, "https://website.com/login.ws"); 
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, "username=".$username."&password=".$password."&dest=title.ws&mod=www&ssl=0");
   $pagedata = curl_exec($ch);
   curl_close($ch);
   
   
   
if (preg_match("/Your login was successful. You will shortly be redirected to your destination./i", $pagedata)) {

$valid = "Valid";
   
   } elseif (preg_match("/Login Failed - Invalid Username or Password/i", $pagedata)) {
    $valid = "Invalid";

} else {
$valid = "Cannot check! Too many invalid logins";
}
echo $valid;  

?>

 

Can someone help me out by turning this into a database run account checker, that means instead of  having to do it 1 by 1 by editing:

$username = "username";
$password = "password";

and reloading the pasge

 

It can just go to a database select a table, and the 2 columns named:

 

user

pass

 

and just go through the rows and check it.

 

Structure of my table:

+---------+------------+-----------+
| user_id |  username  |  password |
+---------+------------+-----------+
|       1 | john12     | thepass   |
|       2 | catman17   | cat       |
+---------+------------+-----------+

Is that possible?

Link to comment
https://forums.phpfreaks.com/topic/179267-turn-hardcode-into-database-run/
Share on other sites

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.