PHP 7 Script to Build a Login Form Using HTML5 and MySQL Database in Browser Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments

 

Welcome folks today in this blog post we will be building a login form using html5 and mysql database in browser using php 7. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.php file and copy paste the following code

 

 

index.php

 

 

<?php
$servername="localhost";
$username="root"; 
$password="";
$dbname="project";
$q=mysqli_connect($servername,$username,$password,$dbname);
?>
  

<html>
<head>
<title>loginpage</title>
</head>
<body>
<h1> login form</h1><br><br><br><br>
<form action="" method="post">
<table>
<tr><td>ENTER YOUR USERNAME</td><td><input type="text" placeholder="username" name="usernameentered" required></td></tr>
<tr><td>ENTER YOUR PASSWORD</td><td><input type="password" placeholder="password" name="passwordentered" required></td></tr>
<tr><td><input type="submit" name="submit" value="submit"></td></tr>
</table>
</form>
</body>
</html>

<?php  

if(isset($_POST['submit']))

 { 

$a=$_POST["usernameentered"]; 

$b=$_POST["passwordentered"]; 

$query1="SELECT * FROM LOGIN WHERE username='$a' && password='$b'";

$data1= mysqli_query($q,$query1); 


$t= mysqli_num_rows($data1);

 if($t==1) 

{

 $_SESSION['user']=$a; echo "successful; 

}

 else

 echo "failed";

}

?>

Leave a Reply