This login script provides the authentication for our web page. This is one page Php login Script using PHP MySQL Select Query. Click the submit button then execute this PHP script.
PHP MySQL Select Query
The basic syntax of the select Query. Example is given below
SELECT column1_name, column2_name, column3_name FROM table_name;
To select all columns from the table using * character.
SELECT * FROM table_name
This is real life MySql database structure. ID is an AUTO_INCREMENT column. It is count number of table rows. The username column is for the username. The password column is for the password and client_status is for the client_status.

How to make this database
Please see follow the number.

How to insert data in the Mysql database table
Open MySql database select table and then click the SQL tab and put this sql quarry given below and then click the GO button.
INSERT INTO `member` (`id`, `username`, `password`, `client_status`) VALUES ('1', 'saurav@gmail.com', '123456', 'active ');

Our database is created and show database value. ID,username,password,client_status is a table Field name.

PHP Login Form with Sessions
This is a login.php page. First, include config.php. config.php is a database connection page. Next start Session variables. This Session store individual client information. Next if condition. User press the login form submit button then this condition is executed. Condition is to catch this server value $myusername,$mypassword PHP variables, and execute PHP MySQL Select Query. When all three condition is match then login now be successful. my_client2 is MySQL database table name. This $rows value is not empty then redirect dash.php otherwise redirect login.php. If you have deactivated client_status value then logging will not be successful.
include("config.php"); session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { $myusername=$_REQUEST["username"]; $mypassword=$_REQUEST["password"]; { $query = "SELECT * FROM my_client2 WHERE username='$myusername'AND passcode='$mypassword' AND client_status='active'"; $result = mysqli_query($db,$query) or die(mysql_error()); $rows = mysqli_num_rows($result); if($rows!="") { $_SESSION['name'] = $myusername; // Redirect user to dash.php header("Location:dash.php?u=$myusername"); } else { header('Location:login.php'); } } } ?>Untitled Document</title>
config.php
define('DB_SERVER', 'localhost'); define('DB_USERNAME', 'domaincom_client'); define('DB_PASSWORD', 'jj888iik9ij8@'); define('DB_DATABASE', 'domaincom_db'); $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE); ?>
logout.php
session_start(); if(session_destroy()) { header("Location: login.php"); } ?>