User Registration Login & Logout with PHP and MySQLi using Session

Hi, friends in this tutorial I show you how to create user registration, login & logout with PHP and MySQLi using session. User registration/login system is one of the important parts of all websites and the knowledge to build them is must have a skill for any web developer. In this post, let us see how to create a complete login and registration system using PHP and MySQL database. This tutorial is fairly easy to understand, it covers as much as needed to build advanced registration/login system. For this, I used data validation to keep PHP sessions for validated access.

User Registration Login & Logout with PHP and MySQLi using Session – (Part- I)

User Registration Login & Logout with PHP and MySQLi using Session – (Part- II)

register.php
login.php
welcome.php
logout.php

Download

Was this article helpful?

Yes No
×

How can we improve it?

×

We appreciate your helpul feedback!

Your answer will be used to improve our content. The more feedback you give us, the better our pages can be.

Follow us on social media:

Facebook Pinterest

Mraj

Creative Designer & Developer specialist by the spirit and a loving blogger by thoughts.

6 thoughts on “User Registration Login & Logout with PHP and MySQLi using Session

  1. you help me so much! thanks to you. ive subscribe your channel in youtube. we hope you post more tuts about displaying data in php..

  2. I am getting a database error. Please help.

    <?php
    if(isset($_POST["submit"])){
    if(!empty($_POST['user']) && !empty($_POST['pass'])){
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    //DB Connection

    $mysqli = new mysqli('localhost', 'thanos', '\$piderman2') or die(mysqli_error());

    //Select DB From database
    $db = mysqli_select_db($mysqli, 'SBio') or die("database error");
    //Selecting database
    $query = mysqli_query($mysqli, "SELECT * FROM userpass WHERE user='".$user."' AND pass='".$pass."'");
    $numrows = mysqli_num_rows($query);
    if($numrows !=0)
    {
    while($row = mysqli_fetch_assoc($query))
    {
    $dbusername=$row['user'];
    $dbpassword=$row['pass'];
    }
    if($user == $dbusername && $pass == $dbpassword)
    {
    session_start();
    $_SESSION['sess_user']=$user;
    //Redirect Browser
    header("Location:index.php");

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top

DON’T MISS ANY UPDATE

Get notified about the next update

Pin It on Pinterest