Login and Registration System with Email Verification in PHP MySQL

1 453

A “Login and Registration System with Email Verification in PHP MySQL” is a comprehensive web application that provides user authentication features, allowing users to register, log in, and ensuring the security of user accounts through email verification.

This type of system is commonly used in websites or applications where user authentication and account security are crucial, providing a robust and reliable mechanism for user registration and login. It is essential to keep the system updated, regularly perform security audits, and stay informed about best practices to ensure a secure and user-friendly experience.

Features:

  • User Registration and Login:
    • User Registration: This functionality allows new users to create accounts on the system. Users provide necessary details such as their name, email address, and a secure password. The system typically employs password hashing for security. Upon successful registration, user data is stored in the database.
    • User Login: Registered users can log into the system by providing their email and password. The system verifies the entered credentials against the stored information in the database. Successful login results in user authentication, granting access to protected areas of the application.
  • Email Verification:
    • After user registration, an email verification process is initiated. Users receive a confirmation email containing a unique verification link or token. Clicking the link or entering the token confirms the user’s email address. This step ensures that the provided email is valid and helps prevent unauthorized account creation.
  • User Management:
    • User Data Storage: User details, including name, email, and other relevant information, are stored in a database. Each user typically has a unique identifier (user ID) for easy retrieval and management.
    • User Profile: The system manages user profiles, allowing users to view and edit their own information. User profiles may display details such as name, email, and any additional information collected during registration.
  • Update User and Delete:
    • Update User: Registered users can update their information, such as name, email, or password, through a user-friendly interface. The system ensures proper validation and security measures during the update process.
    • Delete User: Users have the option to delete their accounts. This process involves removing user data from the database.
  • Logout:
    • The logout functionality allows users to end their current session. When a user logs out, the system destroys the session, ensuring that any subsequent requests require re-authentication. This helps secure user accounts, especially on shared devices or public computers.

How to use code

Creating Database

  • Open Phpmyadmin in your Browser
  • Click on Database Tab Display on Top side
  • Give the Database name “emailverify”.
  • After Creating Database Open it.
  • Click on SQL Tab on Top area
  • Copy the Below Source Code and paste it.
  • Then Click on Go.
-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Feb 02, 2024 at 09:58 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `emailvr`
--

-- --------------------------------------------------------

--
-- Table structure for table `tbl_user`
--

CREATE TABLE `tbl_user` (
  `tbl_user_id` int(11) NOT NULL,
  `first_name` varchar(255) NOT NULL,
  `last_name` varchar(255) NOT NULL,
  `contact_number` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `username` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  `verification_code` int(6) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `tbl_user`
--

INSERT INTO `tbl_user` (`tbl_user_id`, `first_name`, `last_name`, `contact_number`, `email`, `username`, `password`, `verification_code`) VALUES
(1, 'admin', 'profile', '12345678960', 'admin@admin.com', 'admin', '00124578', 277990);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `tbl_user`
--
ALTER TABLE `tbl_user`
  ADD PRIMARY KEY (`tbl_user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `tbl_user`
--
ALTER TABLE `tbl_user`
  MODIFY `tbl_user_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

OR Import DB File

After Downloading the source code extract it in your root folder.

  • Open Phpmyadmin in your Browser
  • Click on Database Tab Display on Top side
  • Give the Database name “emailverify”.
  • After Creating Database Open it.
  • Click on Import Tab on Top area
  • You can Find Db file in  Downloaded source code Select it.
  • Then Click on Go.

Connect Database

  • $servername: Specifies the MySQL server location (in this case, localhost).
  • $username: Specifies the MySQL username (in this case, root).
  • $password: Specifies the MySQL password (in this case, an empty string).
  • $db: Specifies the name of the database (in this case, emailverify).
<?php 
$servername = "localhost";
$username = "root";
$password = "";
$db = "emailvr";
try {
    $conn = new PDO("mysql:host=$servername;dbname=$db", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    echo "Failed " . $e->getMessage();
}
?>

Screenshots

Login and Registration System with Email Verification in PHP MySQL Login and Registration System with Email Verification in PHP MySQL Login and Registration System with Email Verification in PHP MySQL Login and Registration System with Email Verification in PHP MySQL

Download the Complete source code in zip Formate by clicking the below button Download Now otherwise you can send Comment.

Download Source Code

1 Comment
  1. Sushil kumar says

    Thankyou so much

Leave A Reply

Your email address will not be published.