We are going to create
Login using MD5 in PHP. This source code will help you on how to create a simple login form with MD5 Encryption. It has input validation does not allow the user to enter in the home page if the form field was empty and password is being encrypted using the MD5.
We have sample source code for the form field below. Take a look and kindly study the code. Then, try it.
<form class="form-horizontal" method="POST"> <div class="control-group"> <label class="control-label" for="inputEmail">Username
</label> <input type="text" id="inputEmail" name="username" placeholder="Username" required> <div class="control-group"> <label class="control-label" for="inputPassword">Password
</label> <input type="password" name="password" id="inputPassword" placeholder="Password" required> <div class="control-group"> <button type="submit" name="login" class="btn btn-primary">Login
</button> <?php
if (isset($_POST['login'])){
$username=$_POST['username'];
$password=md5($_POST['password']);
$login=mysql_query("select * from user where username='$username' and password='$password'")or die(mysql_error());
$count=mysql_num_rows($login);
if ($count > 0){
header('location:home.php');
}else{ ?>
<div class="alert alert-error">Error login! Please check your username or password
</div> <?php
}}
?>
Username :
admin
Password:
admin
Output
![Result](https://www.sourcecodester.com/sites/default/files/login_1.jpg)
Hope that this simple source code will help you a lot. Thank you.