Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Any1 know how to do this ?

  1. #1
    Waffles!! GregT is on a distinguished road GregT's Avatar
    Join Date
    Feb 2002
    Location
    Michigan
    Posts
    2,496

    Any1 know how to do this ?

    Does ne1 know how to make a php or perl script that is like host.sk's createdb.php ? i tryed to make my own but failed miserably, and the person that gives me this script will have there name and website on the bottom of the script , i will prolly have lots of traffic to this page
    Insert lame joke here.

  2. #2
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    that's easy to do...i could do one, but i need to know where the script gets all user names and passwords from...from a database to check if they are really hosting members ?
    Last edited by hohoho; June 9th, 2002 at 02:23.
    There are 3 kinds of people: the ones who can count and the others who cannot

  3. #3
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    ok...my script is nearly finished...it creates a db called PLDusername, and it creates a mysql user(same username/pass) with rights only in this database
    There are 3 kinds of people: the ones who can count and the others who cannot

  4. #4
    Waffles!! GregT is on a distinguished road GregT's Avatar
    Join Date
    Feb 2002
    Location
    Michigan
    Posts
    2,496
    thnx u so much mitja ! all the usernames and passwords are stndard UNIX usernames and passwords so there is no database,
    Insert lame joke here.

  5. #5
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    hmm, i never worked with UNIX/Linux
    but it should look like this if it was in a database...you can edit it beause i don't know how it works with unix users...
    PHP Code:
    <?
        
    if(isset($submit))
          
    checkuser($username$password);
        else {
        echo 
    "<form action=$PHP_SELF method=post>
        Username: <input name=username><br>
        Password: <input type=password name=password><br>
        <input type=submit name=submit value=Submit><input value=Reset type=reset></form>"
    ;
        }

    function 
    checkuser($username$password) {
        
    $sqlserver "localhost";  // You NEED to change these 3 variables
        
    $sqluser "user";      // an mysql user who has all rights
        
    $sqlpass "pass";         // his password

        
    $link mysql_connect ($sqlserver$sqluser$sqlpass)
            or exit (
    "Couldn't connect to Database Server");

        
    $res mysql_db_query("users""SELECT * FROM members");
        
    $num mysql_num_rows($res);
        for(
    $i=0;$i<$num;$i++)
        {
            
    $user mysql_result($res$i"user");
            
    $pass mysql_result($res$i"pass");
            
    $password2 md5($password);
            if(
    strcmp($username$user)==&& strcmp($password2,$pass)==0)
               
    createdb($user$password);
            exit;
        }
    }
        
    function 
    createdb($user$pass) {        
        
    $datab "PLD$user";
        if (
    mysql_query("CREATE DATABASE $datab")) {
            print (
    "Database was created sucessfully\n");
        } else {
            
    printf ("Error: %s\n"mysql_error ());
        }
        
    $sql "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON $datab.* TO $user@localhost IDENTIFIED BY '$pass'";
        
    mysql_query($sql);
    }
    ?>
    I tested it on my computer and it worked
    There are 3 kinds of people: the ones who can count and the others who cannot

  6. #6
    Waffles!! GregT is on a distinguished road GregT's Avatar
    Join Date
    Feb 2002
    Location
    Michigan
    Posts
    2,496
    i dont need user checking as the script will be secured with .htaccess , what would the code be that just creates a db and user with the filled out info (the entire chking process cut out)
    Insert lame joke here.

  7. #7
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    it's this funtion:
    PHP Code:
    function createdb($user$pass) {        
        
    $datab "PLD$user";
        if (
    mysql_query("CREATE DATABASE $datab")) {
            print (
    "Database was created sucessfully\n");
        } else {
            
    printf ("Error: %s\n"mysql_error ());
        }
        
    $sql "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON $datab.* TO $user@localhost IDENTIFIED BY '$pass'";
        
    mysql_query($sql);

    There are 3 kinds of people: the ones who can count and the others who cannot

  8. #8
    Waffles!! GregT is on a distinguished road GregT's Avatar
    Join Date
    Feb 2002
    Location
    Michigan
    Posts
    2,496
    ok but , how do i take the info from the form

    PHP Code:
        echo "<form action=$PHP_SELF method=post>
        Username: <input name=username><br>
        Password: <input type=password name=password><br>
        <input type=submit name=submit value=Submit><input value=Reset type=reset></form>"
    ;
        } 
    and change it to $user and $pass

    would it be

    PHP Code:

    $user 
    username

    $pass 
    =password 
    ?

    plz help
    Insert lame joke here.

  9. #9
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    hmmm..i don't really know what you mean, but i think it should look like this
    PHP Code:
    <?
        
    if(isset($submit))
          
    createdb($username$password);
        else {
        echo 
    "<form action=$PHP_SELF method=post>
        Username: <input name=username><br>
        Password: <input type=password name=password><br>
        <input type=submit name=submit value=Submit><input value=Reset type=reset></form>"
    ;
        }

    function 
    createdb($username$password) {        
        
    $datab "PLD$user";
        if (
    mysql_query("CREATE DATABASE $datab")) {
            print (
    "Database was created sucessfully\n");
        } else {
            
    printf ("Error: %s\n"mysql_error ());
        }
        
    $sql "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON $datab.* TO $username@localhost IDENTIFIED BY '$password'";
        
    mysql_query($sql);
    }
    ?>
    There are 3 kinds of people: the ones who can count and the others who cannot

  10. #10
    Waffles!! GregT is on a distinguished road GregT's Avatar
    Join Date
    Feb 2002
    Location
    Michigan
    Posts
    2,496
    with that code i get Error: Access denied for user: '@localhost' to database 'PLD'
    Insert lame joke here.

  11. #11
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    oh, i forgot the mysql connection code...
    PHP Code:
    <?
        
    if(isset($submit))
          
    createdb($username$password);
        else {
        echo 
    "<form action=$PHP_SELF method=post>
        Username: <input name=username><br>
        Password: <input type=password name=password><br>
        <input type=submit name=submit value=Submit><input value=Reset type=reset></form>"
    ;
        }

    function 
    createdb($username$password) {        
        
    $sqlserver "localhost";  // You NEED to change these 3 variables
        
    $sqluser "user";      // an mysql user who has all rights
        
    $sqlpass "pass";         // his password

        
    $link mysql_connect ($sqlserver$sqluser$sqlpass)
            or exit (
    "Couldn't connect to Database Server");
        
        
    $datab "PLD$username";
        if (
    mysql_query("CREATE DATABASE $datab")) {
            print (
    "Database was created sucessfully\n");
        } else {
            
    printf ("Error: %s\n"mysql_error ());
        }
        
    $sql "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON $datab.* TO $username@localhost IDENTIFIED BY '$password'";
        
    mysql_query($sql);
    }
    ?>
    There are 3 kinds of people: the ones who can count and the others who cannot

  12. #12
    Waffles!! GregT is on a distinguished road GregT's Avatar
    Join Date
    Feb 2002
    Location
    Michigan
    Posts
    2,496
    thnx works great now, thnx mitja ! (i made two little changes to thnx u)

    PHP Code:
    <? 
    if(isset($submit)) 
    createdb($username$password); 
    else { 
    echo 
    "<form action=$PHP_SELF method=post> 
    Username: <input name=username><br> 
    Password: <input type=password name=password><br> 
    <input type=submit name=submit value=Submit><input value=Reset type=reset></form><br>
    dbmake.php made by mitja"



    function 
    createdb($username$password) { 
    $sqlserver "localhost"// You NEED to change these 3 variables 
    $sqluser "user"// an mysql user who has all rights 
    $sqlpass "pass"// his password 

    $link mysql_connect ($sqlserver$sqluser$sqlpass
    or exit (
    "Couldn't connect to Database Server"); 

    $datab "PLD$username"
    if (
    mysql_query("CREATE DATABASE $datab")) { 
    print (
    "Database was created sucessfully\n <br><br> dbmake.php made by mitja"); 
    } else { 
    printf ("Error: %s\n"mysql_error ()); 

    $sql "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON $datab.* TO $username@localhost IDENTIFIED BY '$password'"
    mysql_query($sql); 

    ?>
    Insert lame joke here.

  13. #13
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    you can test the script now...i signed up for PLH and need a mysql database lol
    There are 3 kinds of people: the ones who can count and the others who cannot

  14. #14
    Waffles!! GregT is on a distinguished road GregT's Avatar
    Join Date
    Feb 2002
    Location
    Michigan
    Posts
    2,496
    go to http://www.project-linux.org/dbmake.php to signup for dbs ! (Warning do not abuse this script i still need to put a .htaccess file on this to protect it
    Insert lame joke here.

  15. #15
    Pro Member hohoho is an unknown quantity at this point hohoho's Avatar
    Join Date
    Apr 2002
    Location
    localhost
    Posts
    456
    wow...it really works
    if someone tries to abuse, then it will tell him the database already exists
    There are 3 kinds of people: the ones who can count and the others who cannot

Closed Thread

Bookmarks

Posting Permissions

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