Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    705
    Thanks
    8
    Thanked 17 Times in 16 Posts

    Turn Hardcode into Database Run

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

    PHP Code:
    <?php
    $username 
    "username";
    $password "password";

       
    $ch curl_init();
       
    curl_setopt($chCURLOPT_URL"https://website.com/login.ws"); 
       
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
       
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
       
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
       
    curl_setopt($chCURLOPT_POST1);
       
    curl_setopt($chCURLOPT_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:
    Code:
    $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:
    Code:
    +---------+------------+-----------+
    | user_id |  username  |  password |
    +---------+------------+-----------+
    |       1 | john12     | thepass   |
    |       2 | catman17   | cat       |
    +---------+------------+-----------+
    Is that possible?
    Last edited by bucket; 10-27-2009 at 11:46 PM.

  • #2
    Regular Coder
    Join Date
    Sep 2008
    Posts
    705
    Thanks
    8
    Thanked 17 Times in 16 Posts
    Bump.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •