user-registration-form

User Registration Form Using PHP & HMTL

Hello Friends,

In this blog post, I will explain to you how to make a simple user registration form using PHP?

Registration form is very important function when you have user account facility on your website,

whether it is for subscription based service or selling a product.

In this Registration for User will enter the username and password in a form and will submit their data to your database.

This will help them to login into their account on your website as their username and database will be stored in your database.

You can see the below image for the same.

regis2


Software used for building this functionality is given below:

Install NetBeans IDE
Install Xampp Server


What is the procedure for making this registration functionality?

this is a very simple functionality, you just need to follow the step by step procedure given below.

First, open the Netbeans IDE.

Start the Apache server and MySql server using Xampp.

If you don’t know how to start Xampp Server then please go through this link.

Now create a database name as a test.

Create a table name as login with two fields, username, and password.

Now create a new project in your NetBeans IDE as User_Registration though you can have named as per your wish.

Now create few more file as shown in the below image.

regis1

Once you create all the file then just copy and paste the below code one by one in the respective files.

index.php:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="formregister.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<h3>Registration Form</h3>
<form action="#" method="get" id="registerform">
<input type="text" name="username" placeholder="UserName"></input><br/>
<input type="password" name="password" placeholder="PassWord"></input><br/>
<input type="submit" name="submit" value="Submit"></input>
</form>

<?php
if (isset($_GET['submit'])) {
$con = mysql_connect("localhost", "root", "");
//Selecting Database
$db = mysql_select_db("test", $con);

$username = $_GET['username'];
$password = $_GET['password'];

if($username==""||$password=="")
{
echo"Please fill all the fields";
}
else{

$query=mysql_query("insert into login (username, password) values ('$username','$password')");
echo"Your data has been submitted successfully";

mysql_close($con); // Closing the connection
}

}
?>
</body>
</html>

formregister.css:

#registerform{
text-align:center;
border:1px solid #ccc;
width:300px;
padding:0 50px 15px;
margin-top:20px;
box-shadow:0 0 15px;
border-radius:6px;
float:left;
background-color: lightgray;
margin-left: 475px;

}
input[type="submit"]{
width:100%;
padding:10px 45px;
background-color:#2BC1F2;
border:none;
color:#fff;
font-size:18px;
font-weight:700;
cursor:pointer;
font-family: 'Spectral', serif;
margin-left:10px;

}
input[type="text"]{
width:100%;
margin-top:10px;
height:35px;
margin-bottom:25px;
padding:10px;
border:3px solid darkslateblue;
}
input[type="password"]{
width:100%;
margin-top:10px;
height:35px;
margin-bottom:25px;
padding:10px;
border:3px solid darkslateblue;

}
h3{
text-align: center;
}

Now run your project and you will get a registration form ready for your users.


In a case of any queries, you can write us at anurag@a5theory.com we will get back to you ASAP.

Hope! you would have enjoyed this post.

Please feel free to give your important feedbacks in the comment section below.

Have a great time! Sayonara!