Today, We want to share with you logout in php.In this post we will show you how to use session in php for login form with example, hear for how to create login page in php and mysql with session we will give you demo and example for implement.In this post, we will learn about login form in php with session and validation with an example.
login and logout using session in php and mysqli
There are the Following The simple About session in php example for login and Sign out without database Full Information With Example and source code.
As I will cover this Post with live Working example to develop Sign out code in php, so the ,
is used for this example is following below.
In this login Sign out example in PHP we used 3 file
- login.php
- index.php
- logout.php
Step 1: Login in PHP Database Structure
login_member.sql
CREATE TABLE `login_member` ( `id` int(11) NOT NULL, `name` varchar(60) NOT NULL, `member_name` varchar(20) NOT NULL, `password` varchar(20) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Step 2: Login in PHP
login.php
0) { $con = mysqli_connect('127.0.0.1:3306','root','','admin') or die('Unable To connect'); $result = mysqli_query($con,"SELECT * FROM login_member WHERE member_name='" . $_POST["member_name"] . "' and password = '". $_POST["password"]."'"); $data = mysqli_fetch_array($result); if(is_array($data)) { $_SESSION["id"] = $data['id']; $_SESSION["name"] = $data['name']; } else { $message = "Invalid membername or Password!"; } } if(isset($_SESSION["id"])) { header("Location:index.php"); } ?>member Login
Step 3: Main index Landing pages
index.php
member Login Welcome . Click here to Logout. Please login first ."; ?>
Step 4: Logout in PHP
logout.php
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about logout in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.