Complete User Login & Registration System using PHP MySQL With Image Upload

Complete User Login Registration System in PHP with Image upload, In this article we will create both a PHP register and login system where we will also upload images for all the users as part of the user profile.

Complete User Login & Registration System using PHP MySQL With Image Upload
Complete PHP User Login and Registration System with Image Upload

Here are some major Steps to create a PHP User Login and Registration System with Image upload,

5+ Steps to Create PHP Code For Registration Form with MySQL Database

  1. Create Database
  2. Create Database Table with the following fields: name, username, password, city, image, and gender.
  3. Create a PHP registration functionality
  4. Create a Login Form
  5. Connect to the MySQL Database
  6. Authenticate Logged in User
  7. Create a Home Page with all User data

Create Database

To create a database, go to PHPMyAdmin and click on SQL Tab. On the SQL tab write below the given query which creates the DB with the given name.

Create Database Table

Execute the below query which can create the DB table with the listed fields,

Connect to Database

To establish the connection to MySQL DB or PHPMYADMIN we create a file named connect.php where we use mysqli_connect() function.

connect.php

Create a PHP Registration Form functionality

Here we will create a PHP register script, first, we will create an HTML form with the POST method, also get the user data using the POST method, and insert it into the database with image upload.

register.php

Creating a Login Form with Functionality

Here we will create an HTML form with a username and password field. Also, we will create a user authentication query using the same username and password MySQL query and redirect to the home page.

login.php

Authenticate Logged in User on Redirection

Here we will authenticate the user on the home page redirection after login. If anyone directly wants to access the home page it checks whether the user is currently logged in or not.

Creating Home Page

After successful login user enters the home page and also sees their data with an image and also logs out from there.

home.php

Creating a Logout page

For creating a logout operation we have to destroy the session using the PHP session_destroy() function.

logout.php

Image Upload using PHP MySQL Snippet

For uploading the image we make sure using enctype="multipart/form-data" on form tag, like given below.

For image uploading, the PHP MySQL code snippet is given below,

To know more about file upload: https://www.php.net/manual/en/features.file-upload.php

Download Simple PHP CRUD Operation source code:

https://codingtasks.net/download/download-source-code-simple-php-mysql-crud-operation/

Also, check:

Complete tutorial to complete login and registration system with PHP & MySQL with Image upload which helps to develop a small PHP project.

Happy Coding..!

Was this article helpful?
YesNo

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

5 thoughts on “User Login Registration System in PHP with Image Upload”
  1. dear Admin I need to View Sql Data(images) in horizontal same line.

    my source code is as follows please help me:

    runQuery(“SELECT * FROM tbl_image ORDER BY ‘id’ ASC “);
    if (! empty($query)) {
    foreach ($query as $key => $value) {
    ?>

    <img src="”/>

    <img src="width=”96px” height=”56px”/>

    1. Hi,
      Please check this. If anything else please let me know.

      <?php
      $qry = mysqli_query(“SELECT * FROM tbl_image ORDER BY ‘id’ ASC”);
      while($f=mysqli_fetch_assoc($qry)){ ?>
      <img src=”image_directory_loaction/<?php echo $f[‘image.png’];?>” width=”96px” height=”56px”>
      <?php } ?>

Leave a Reply

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