Login using MD5 in PHP
Submitted by alpha_luna on Thursday, September 29, 2016 - 16:15.
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.
Username : admin
Password: admin
- <form class="form-horizontal" method="POST">
- <div class="control-group">
- <div class="controls">
- <input type="text" id="inputEmail" name="username" placeholder="Username" required>
- </div>
- </div>
- <div class="control-group">
- <div class="controls">
- <input type="password" name="password" id="inputPassword" placeholder="Password" required>
- </div>
- </div>
- <div class="control-group">
- <div class="controls">
- </div>
- <br>
- <?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{ ?>
- <?php
- }}
- ?>
- </div>
- </form>
Output
Hope that this simple source code will help you a lot. Thank you.Add new comment
- 283 views