...

View Full Version : Turn Hardcode into Database Run



bucket
10-28-2009, 12:08 AM
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 page

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?

bucket
10-28-2009, 12:46 AM
Bump.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum