Basic Login Form in PHP with MySQL database connectivity
Hello friends today in this blog you will learn PHP Login form in PHP with MYSQL database connectivity.
In the earlier blog, I have shared to create an Accordion using HTML and CSS only, Now it's time to learn Login form in PHP with MySQL database connectivity.
I'm happy to post here my insight and methods utilized in PHP and MySQL. As you all mindful that PHP and MySQL are the most broadly utilized open source for sites. the present great many sites and application are utilizing these free software's.
Actually I feel that this could be next level for front end engineers by utilizing PHP and MySQL a HTML designer can make a site more unique. Allow us to talk about How to make a Basic Login form in PHP with database, Its straight forward and exceptionally valuable for an essential site dynamic client dynamic enlistment.
Each innovative can execute its essential construction to their site. Presently Just follow these basic advances and you will find that your first dynamic functional PHP registration form with database connection entry on every form fill up.
So here is the code and my work. I hope you are gonna love this and share with you friends too. So let's start learning PHP Login Form in PHPP with MySQL database connectivity.
STEP 1: Create Database for inserting values
CREATE TABLE `login` (`id` int(11) NOT NULL,`uname` varchar(50) NOT NULL,`pswd` varchar(255) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
STEP 2: Create HTML Login Form (Front end code)
Create a new file index.php, Here is the code
<!DOCTYPE html><html><head><title>Create a Login Page in HTML and CSS Using PHP</title><link rel="stylesheet" type="text/css" href="style.css"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"></head><body><form method="post" action="login.php"><h2>Login</h2><input type="text" name="uname" placeholder="Ussername" id="textBox"><input type="password" name="pswd" placeholder="Passowrd" id="textBox"><input type="submit" name="submit" value="Login" id="btn"><div id="msg"><?php echo $msg; ?></div></form></body></html>
STEP 3: For Database connectivity using MySQL
Make a connection.php file for stablished connection database use that default code as below
$conn = mysqli_connect("localhost","root","","tutorials");
STEP 4: Finally make a login page with login.php extension
From get value of all fields shown in HTML page
<?phpinclude("connection.php");$msg='';if(isset($_POST['submit'])) {$uname = $_POST['uname'];$pswd = $_POST['pswd'];if($uname!='' && $pswd!='') {$query = mysqli_query($conn,"select * from login where uname='$uname' and pswd='$pswd'");$check = mysqli_num_rows($query);if($check>0) {header("location:welcome.php");}else{$msg = "Enter a valid Ussername and Password";}}else{$msg = "Enter your ussername and password";}}?>
Here a Front end developer can keep in touch with some own code in PHP, Read the code and comprehend this essential design line by line you will think that its extremely simple.
Conclusion
By following bit by bit strategy gave over a fundamental login form can be made. So best of luck for your first
PHP code.

0 Comments