LOGIN/SIGNUP FORM WITH SESSION IN PHP MYSQL - CULT CODE
In this tutorial, We will learn how to create a Signup and Login form in PHP MySql with Session Management and Exist condition. 1. Create a table name user. Use the code below to create a table: CREATE TABLE `user` ( `id` int(251) NOT NULL, `username` text NOT NULL, `email` text NOT NULL, `password` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 2. Now create a file connect.php: This file will help us to connect PHP to Mysql. <?php $connect = mysqli_connect("localhost", "root", "password", "demo"); ?> 3. Now create a file index.php: After Signup/Sign-in user will be redirected to this page. <?php session_start(); if (!isset($_SESSION['username'])) { header("location: login.php"); } elseif (isset($_GET['logout'])) { session_destroy(); unset($_SESSION['username']); header("location: login.php"); } ?> <!DOCTYPE ht...


Comments
Post a Comment