Referensi para programer

Advertisements

Breaking

Friday 28 April 2017

How to create login using password encrypt MD5



Good night my dear blog visitors 😀 at this time I will give a tutorial how to create a simple login that uses encrypt password md5. Before I will explain what is Encrypt and Decrypt.

    
Encryption is a process that aims to "blur / alter" information to make the information unreadable without special knowledge. (Plain text -> encrypt -> result)
    
Decrypt is equally important, that is to convert the encrypted result into an understandable and understandable original text (encrypt -> decrypt -> plain text)While the definition md5 has hash function in cryptography used with 128-bit hash value. In Internet standards (RFC 1321), MD5 has been used in many ways in security applications, and MD5 is very commonly used to perform the integrity testing of a file.Okay just start kodingnya ..

    
Create a new database with the login name, which contains the "tbuser" table: id, username, password

CREATE TABLE `blog_tes1`.`tbuser` ( `id` INT(5) NOT NULL AUTO_INCREMENT , `username` VARCHAR(30) NOT NULL , `password` VARCHAR(50) NOT NULL , PRIMARY KEY (`id`));
After the database is created, we create a user first with sql command

INSERT INTO `tbuser` (`id`, `username`, `password`) VALUES ('1', 'admin', MD5('admin'));  
Then we create file connection.php, which serves to connect to the database

<?php
$host="localhost";
$user="root";
$pass="";
$db="blog_tes1";
   
$koneksi=mysql_connect($host,$user,$pass);
mysql_select_db($db,$koneksi);

?>

After that we create a login page called login.php

<html lang="en">
<head>
    <title>Tes Login</title>
</head>

  <body style="text-align: center;">

      <form action="proses.php" method="post">
        <h2>Login Area</h2>
                <input type="text" name="username"  placeholder="Username" autofocus></br></br>
                <input type="password" name="password" placeholder="Password"></br></br>
            <button type="submit" name="login">Masuk</button>
      </form>
  </body>
</html>


Then we make the process, to ensure that the username and password are sent in the database

<?php
include "koneksi.php";
if (isset($_POST['login'])){
    //koneksi terpusat

    $username=$_POST['username'];
    $password=md5($_POST['password']);
   
    $admin = mysql_query("select * from tbuser where username='$username' and password='$password'");
    $tot= mysql_num_rows($admin);
    $r= mysql_fetch_array($admin);
if ($tot > 0) {//jika data ada maka akan diproses
 $_SESSION['username'] = $r['username'];

 ?>
<html lang="en">
<head>
    <title>Tes Login</title>
</head>

  <body style="text-align: center;">
  <h2>Selamat Datang <?php print_r($_SESSION['username']); ?></h2>
  </body>
  </html>

  <?php

}else{
    ?>
    <script>alert('Username atau Password Salah Bro!!!!!');</script>
    <?php
}
}
?>

Finished 😀
Good luck and good luck

For the full source code can be downloaded here

DOWNLOAD 
So many tutorials from me, may be useful for all friends :)        

No comments:

Post a Comment