Jump to content

Admin panel on website


oleczek381

Recommended Posts

<?php 
if (isset($_POST['submitb'])) { //If the submit button was pushed 
    $username = $_POST['username']; //Lets get the HTML Info 
    $password = $_POST['password']; 
  
    //config 
     
    $db_host = "localhost"; 
    $db_user = "root"; 
    $db_pass = "your password"; 
    $db_name = "your database name"; 
     
        $kapcs = mysql_connect($db_host,$db_user,$db_pass); 
        mysql_select_db($db_name); 
        $query = "INSERT INTO users (username,password) VALUES('$username','$password')"; //Inserting data to db. 
        $doquery = mysql_query($query,$kapcs); 
    print "Registration Successful.<br>"; //Successful registration. 
        header('refresh:3;url=index.php'); //Redirect to index.php in 3 seconds. 
        } 
} 
else 
{ 
//Print the original HTML Form you are using. 
    print '<form method="POST" ACTION="">'; 
    print '<input type="text" size="30" name="username" maxlength="32" placeholder="Username"><br><br>'; 
    print '<input type="password" size="30" name="password" maxlength="32" placeholder="Password"><br><br>'; 
    print '<input type="submit" value="Register!" name="submitb">'; 
    print '</form>'; 
} 
?> 

Link to comment
Remember to apply some way of stripping slashes and an encryption for the passwords - otherwise no one will join your server if you have none.

Exactly what he is saying, forgot to add that. Use md5, sha1, or even sha256.

Or forget MD5 and SHA1, which both can be brute-forced in one day, or even in a few hours if you have enough GPU power and cores.

I suggest using SHA256 or then just make a strong algorithm mix-up of your own, for example, a little bit of SHA, a little bit of something else, a random salt generator and such.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...