• PHP MySQL Login System – A Super Simple Tutorial

    Hello everyone,
    In this post we are going to create a very simple PHP MySQL login system. At the beginning, we will show a registration form to users and store user given data into MySQL database. Then we will create a login page where we take username and password and let users logged in if username & password combination is correct.
    PHP MySQL Login System Screenshot

    Skills you need

    Basic knowledge on PHP, MySQL and HTML
    In the registration form, we will not sensitize and validate user provided data to keep it as simple as possible. If you don’t know anything about PHP serer-side form validation, I strongly suggest you to check this post below.
    At first, we need to create MySQL database, lets create name it to “php_mysql_login_system” (or of course you can use an existing one). After that,  create a table within the database and name it “users” as all registered users’ information will be stored here. Use the following SQL query below to create the table.
    You can also take help of phpMyAdmin – GUI MySQL DBMS, to create the table if you’re a lazy dev too.
    We will use MySQLi (MySQL Improved) to do all database operations from PHP.

    The Registration Form

    db_const.php

    register.php

    The Login Form

    login.php

    Explanation: how this PHP MySQL login system work

    At the beginning we created a simple registration form and stored some user information to MySQL database. Assume that each user has a unique username and email address (though we have not validated the registration form).
    In the login form, we take a username and password combination from users. Then we query MySQL database with user given username and password combination. After that, if the combination is matched with any of users row, then we let the user logged in, otherwise show error to the user.
    Hope this article helped you. If you need further help, please comment below.
    Thank you!
  • You might also like

    No comments:

    Post a Comment

    Good day precious one, We love you more than anything.

Powered by Blogger.