All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

How To Create Registration Form In HTML With Database

Last Updated : Mar 11, 2024

How To Create Registration Form In HTML With Database

In this tutorial we will show you the solution of how to create registration form in HTML with database, the main things to insert from a user are the user name or id which he/she uses again for login with a password.

So, in this article we create a form with some basic form tags and we will also use php with MySQL of database in this concept. So, be prepare.

Step By Step Guide On How To Create Registration Form In HTML With Database :-

Now, before start coding in ide. You must have a prepared database. We use here MySQL database and create a database in it with a table named registration. Whereas in file of registration is given below.

<?php
$connect = mysqli_connect("localhost", "root", "", "as1") or die("Connection failed");
if(!empty($_POST['submit']))
{
    $username=$_POST['name'];
    $userage=$_POST['age'];
    $useremail=$_POST['email'];
    $userpass=$_POST['password'];
    $query = "insert into registration(username, age, email, password) values('$username', $userage, $useremail, $userpass)";
    if(mysqli_query($connect, $query))
    {
        echo "Record inserted successfully";
        echo "br"."We send you response after verification";
    }
    else
    {
        echo"Soory, there is some error";
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <title>
        registration form
    </title>
</head>
<body style="text-align: center;">
    <h1>
        Registration form
    </h1>
    <h3>
        Fill the following details to register yourself
    </h3>
    <form action="" method="post">
       <label for="">
            Your Name
       </label>
       <input type="text" name="name" id="name">
       <br><br>
       <label for="">
           Your Age
       </label>
       <input type="text" name="age" id="age">
       <br><br>
       <label for="">
           Your email
       </label>
       <input type="email" name="email" id="email">
       <br><br>
       <label for="">
           Your Password
       </label>
       <input type="password" name="password" id="password">
       <br><br>
       <input type="submit" value="Save" name="submit">
    </form>
</body>
</html>
  1. First, we write <! DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in.
  2. Secondly, the <html> tag is used to indicate the beginning of an HTML document.
  3. As above now <head> tag is used to contain information about web page. In this tag a <title> tag is used which helps us to specify a webpage title.
  4. Both <head> and <title> tags are Paired tags. So, both have </head> and </title> ending tags respectively.
  5. Here, we create a registration form with the help of form tag and method used is post. We hope that you understand the form easily because it is too simple. Now, let us discuss php part here.
  6. In php, first we create its opening and closing tag and inside this we make a connection with database with $connect. After this we create an if query and store the data of inputs in variables.
  7. Then with the help of $query we create a link to store the data in database.
  8. Now, there is a last part in which we store data in database and if data stored successfully then it will show message under if condition or if not else part will be executed.
  9. At last, the <body> and <html> tags are closed with </body> and </html> respectively.

Conclusion :-

In conclusion, here we want to say that with the help of this article we are able to create a registration form in html with the help of database.

All the data filled inside input in form is submitted in database. In next session, we will help you to create a login form with database. I hope this tutorial on how to create registration form in HTML with database helps you.

Author Image About Amruta

Amruta is an Experienced web developer with 4 years for experience she completed her master's with MCA and passionate about programming Languages for creating technical contents like HTML, CSS, JavaScript, Java, Python, PHP, jQuery.

Follow Amruta On Linkedin 🡪