• How to create login and logout page with PHP and MYSQL

    Here, I want to explain creating database, posting form values, storing the session value and destroy the session. It is is very useful and simple.

    Set up Database:

    View Code DATABASE
    1
    2
    3
    4
    5
    6
    
    CREATE TABLE admin
    (
    id INT PRIMARY KEY AUTO_INCREMENT,
    username VARCHAR(30) UNIQUE,
    passcode VARCHAR(30)
    );

    Config.php:
    Database configuration file.

    1
    
     

    Login.php:
    Contains PHP and HTML code.



    lock.php:
    Session verification. If no session value page redirect to login.php

    1
    
     

    welcome.php:

    1
    2
    3
    
    <!--?php 
    include('lock.php');
    ?-->

    Welcome

    logout.php:
    SignOut Destroy the session value.

    1
    
     

    Kindly post your comments if you got any bug report.

    Enjoy!!!

    Tags:

Comments on this post

Leave a Reply

  • Security Code :


    8 − = five