Online visitors

People learning around the world

Online

—

Visitors exploring W3Schools

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    PHP Login Script (PHP, MySQL, Bootstrap, jQuery, Ajax and JSON)

    Sometimes you may require protecting your web page by user authentication using the database, and this tutorial can help you to do it.
    This tutorial demonstrates user registration and login process by using PHP and MySQL.

    Features

    • Complete user registration and login management system.
    • User registration data store in MySQL database.
    • Login by using a PHP script and MySQL database and only after authentication user can access to the protected page.
    • Login by using a PHP script and MySQL database and only after authentication user can access to the protected page.
    • Foreign key relationships between MySQL tables.
    • The user can Logout after Login.
    • PHP session is used to keep user login status until logout is clicked.
    • Secured code to prevent SQL injection attacks.
    • Data transmission by using JSON.
    • Bootstrap has been used to improve the user interface.
    • jQuery Ajax is used to submit forms without refreshing the page.

    Database Structure

    Two tables are created in the database to manage user and user profile data separately.

    tbl_users

    DB_tbl_users

    tbl_user_profile

    DB_tbl_user_profile

    Schema

    DB_schema

    • Foreign key relationships exist between these two tables.
    • User profile data will automatically get deleted if data deleted from the user's table.

    Program Structure

    PHP

    • /index.php - This page can only open after authentication; otherwise user will be redirected to the main.php page.
    • /main.php - This page only contains HTML login and registration forms.
    • /submit.php - PHP codes for Login and registration exist on this page, submitted by main.php page.
    • /logout.php - This page is destroying the session started by submit.php page.
    • /inc/config.php - This page is included in all PHP pages and used to start a session and connect with the MySQL database.
    • /inc/functions.php - This page has contained custom PHP functions used in the program.
    • /include/header.php - This page has contains HTML.
    • /include/footer.php - This page has contains HTML.

    JS

    • /js/app.js - This page has contains custom JavaScript which is used to submit Login and Registration forms.
    • /js/jquery.min.js - jQuery Plugin.
    • /js/bootstrap.min.js - Bootstrap Plugin.

    CSS

    • /css/style.js - This page has contains custom CSS.
    • /css/bootstrap.min.css - Bootstrap Plugin.


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.