PHP MySQL Registration Form with Validation

In this tutorial I explain how develop PHP MySQL Registration form with validation. Here we are creating simple signup form which is very helpful for who are in beginning stage of PHP scripting language and MySQL database. In this example we are used Core PHP code to insert user data values from database. You can easily able to understand the code without any struggles. Because the code is very clean and user friendly navigation.

Already we are upload Login form using PHP programming language. That’s why here publish simple example for storing user information. Actually every web application needs signup and login form proceed into further steps. So we can’t skip registration for users to retrieve every details from server side end.

php mysql registration database

In the above we are showing MySQL database table values which is collect user’s information. This tutorial objective is developing simple registration for create new account using both of PHP & MySQL. Moreover here we are not implementing JavaScript or jQuery validation. Execute only HTML validation behind the reason is simple form without any struggle to store data on server.

Features

There is no additionally features, just collect user information such as name, email-id, mobile number, password etc. Later that you can add your own column like Gender, Age, Education, Address and so many fields based on your requirements.

Create Project – PHP MySQL Registration Form

Okay let’s see the steps for how create simple registration form using PHP and MySQL database. First you have to create new form with above mentioned details. After that write connection query to communicate with MySQL database. Moreover e-mail verification is not added on this code. Suppose if you want this just inform us on comment section. Then we will try to individually share the source code on your particular email address.

Technology Used

Below technologies are we are using in this project. For you reference you can apply these technologies same on your project.

Front-EndHTML & CSS
Back-EndPHP
DatabaseMySQL
EditorSublime Text
Developer NameVetrivel Pandian

Source Code

Totally three files are there in this project. So here we are directly explain those source code on this section. Don’t need to download zip file for deploy project on your computer. The database code and PHP files are added here and if face any error just contact us via given email address.

Create Database – PHP MySQL Registration Form

The initial step is you have to create new database and new table with 5 columns. We are adding SQL file for import database and tables on your end. So just create database and then click import button to add .SQL file on your project.

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `email` varchar(50) NOT NULL,
  `password` varchar(50) NOT NULL,
  `mobilenumber` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `name`, `email`, `password`, `mobilenumber`) VALUES
(1, 'vetri', 'jjvetri2@gmail.com', 'vetri', '8778675947'),
(2, 'ram', 'jjvetri2@gmail.com', 'dgfdafdsgsf', '8778675947'),
(3, 'ram', '', '', '8778675947'),
(4, 'ram', '', '', '8778675947'),
(5, 'ram', 'ram@gmail.com', 'afd', '8778675947');

Registration Form

After successfully complete the database step you have o develop registration form for collect information from user side. So create new registration.php file and add the following below code.

<?php
include("db/config.php");
if(isset($_POST['submit'])) 

{
	$name=$_POST['name'];
	$emailid=$_POST['email'];
	$password=$_POST['password'];
	$number=$_POST['mobilenumber'];
$result=mysqli_query($mysqli, "insert into users value('', '$name','$emailid','$password','$number')");
if($result) {
	echo "User Registered Successfully, You can Login Now";
}
else {
	echo "something wrong, data not stored";
}
}
?>

Create Account – PHP MySQL Registration Form

Now time to create user information like name, email address, mobile number, password and more details.

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>My First PHP & MySQL Project</title>
</head>
<body>
	<center><br><br>
<form action="registration.php" method="post">
	Name : <input type="text" name="name" required><br>
	Email : <input type="email" name="email" required><br>
	Password : <input type="password" name="password" required><br>
	Mobile Number : <input type="number" name="mobilenumber" required><br>
	<input type="submit" name="submit" value="Create Account">
</form>
</center>
</body>
</html>

We are not using any CSS for attract the page. Because here our concept is just execute the development functionality only to run the code. And finally create config.php file to connect into MySQL database.

<?php

$hostname='localhost';
$username='root';
$password='';
$databasename='projectphp';

$mysqli =mysqli_connect($hostname,$username,$password,$databasename);

?>

Screenshot – PHP MySQL Registration Form

Just check the output image for further confirmation steps to understand the concepts. For more PHP Projects just visit our other tech blog of Diya Act site.

php mysql registration form with validation

Leave a Reply