PHP program to demonstrate user login | Login System in PHP
Write a PHP program to give authentication for registered users with Database (Login System in PHP)
In this tutorial, you will learn how to give authentication for registered users in php. So, basically we are going to build a Login system in php for registered users.
Below is the php program for login system in php.
<html>
<head>
<title>Login System in PHP</title>
</head>
<body>
<h3>Write a PHP program to give authentication for registered users with Database (Login System)</h3>
<form action="" method="POST">
<label>Username</label><br>
<input type="text" name="username"><br>
<label>Password</label><br>
<input type="password" name="password"><br>
<input type="submit" name="submit">
</form>
<?php
$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection,'database_name');
if(isset($_POST['submit']))
{
$name = $_POST['username'];
$pswd = $_POST['password'];
$query = mysqli_query($connection,"SELECT username,password FROM usersTable WHERE username='$name' and password='$pswd'");
if($query)
{
if(mysqli_num_rows($query) > 0)//returns rows of data from table
echo 'Login Success';
else
echo 'Login failed';
}
}
?>
</body>
</html>
Thanks for reading.
Latest Posts
PHP program to demonstrate user login | Login System in PHP PHP program to format the date functions in php PHP program to display Good Morning / Good Afternoon / Good Evening message according to current time. PHP program to fetch data from database and display in a HTML table Count Number of Visits on a web page using cookies in php PHP program to develop E-mail registration form PHP program to create a .txt file and write some content in it. PHP program to find out maximum and minimum number in an array PHP program to reverse an array PHP program to replace one string using another string in php© Copyright - 2018 - 2022 | All rights reserved at Funda of Web IT