how to create a registration form in php with mysql DATABASE


Hello readers in this article we will learn how to create a registration form in php with mysql database. 

There are two view pages i.e., signup.php and success.php, signup.php will be used to take input from the users and validate the user inputs i.e username password and confirm password. 

If everything goes right then user registration will be successful l and user will be redirected to success.php, see below eample.




   $query=mysqli_query($connect1,"INSERT INTO signup VALUES('$username','$pwd')");
   $_SESSION['username'] = $username;
            echo "
     <script>alert('Success! Redirecting To Success Page');
    function Validate(){
             var id=document.getElementById('id');
             var pwd=document.getElementById('pwd');
             var cpwd=document.getElementById('cpwd');
             var sc=document.getElementById('sc');
             var iderror=document.getElementById('iderror');
             var pwderror=document.getElementById('pwderror');
             var cpwderror=document.getElementById('cpwderror');
             //reset error msg
          if(id.value.length<6  || id.value.length > 20){
             iderror.innerHTML="Username Must be 6 To 20 Character Long";
         else if(pwd.value.length<6 || pwd.value.length >15){
             pwderror.innerHTML="Password Must Be 10 To 15 Character Long";
         else if(cpwd.value!=pwd.value){
           cpwderror.innerHTML="Password Mismatch";

<!DOCTYPE html>
<html lang="en">   
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
      <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="">
  <body >
      <div class="container" style="margin-top:-32px">
          <div class="col-lg-4"></div>
             <div class="col-lg-4">        
                <div class="jumbotron" style="margin-top:80px; background:linear-gradient(skyblue 80%,orangered 20%);"><br>
         <h3><font color=orangered>Signup Please</font></h3>
        <form method="post"  action="" name="myForm">
        <div class="form-group">
            <label><font color=white>Username:</font></label>
            <input type="text" class="form-control" id="id" name="id"  placeholder="UserName..." >
            <font color="red"><?php echo $msg1; ?></font>
            <div id="iderror"></div>
        <div class="form-group">
            <label><font color=white>PASSWORD:</font></label>
            <input type="password"  class="form-control" id="pwd" name="pwd" placeholder="Password 6 to 10 char only ">
            <div id="pwderror"></div>   
        <div class="form-group">
            <label><font color=white>CONFIRM PASSWORD:</font></label>
            <input type="password" placeholder="Confirm password..." class="form-control" id="cpwd" name="cpwd">
            <fonr color="red"><?php echo $cmsg;?></font>
            <div id="cpwderror"></div>  
       <button type="button" class="btn btn-primary" onclick="Validate()" >SignUp </button>
        <button type="button" class="btn btn-danger" onclick="login_page()">Login? </button></form>
           function login_page(){
               document.write("<font color=blue>"+'please wait while redirecting to login page...'+"</font>");

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src=""></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>

 echo "Please Login First To Access This Page";
    SignUp Success
        <b><?php echo $_SESSION['username'];?></b>

Hope this tutorial was helpful.

No comments

You May Like Also

Programming Knowledge

Java JDK
Reversing String in Java
Java Generic Concept With Simple Example
Java Generic Objects Behavior In Non-Generic Area
Creating Connection With MySql Databse Using Java Application
Performing Database Operations Java MySql Insert Update Delete Select
Java Inserting Data in MySql Databse Table
Java Basic Login System Using MySql Database Table
JSP Login System Using MySql Databse
Jsp Servlet Login And Logout System Using Mysql Database Table
What is jdk in Java?
Exaplain inheritance in Java with example?
Exaplain polymorphism in Java with example?
Exaplain abstraction in Java with example?
Exaplain encapsulation in Java with example?
What is the use of this keyword in Java?
Explain ArrayList With Example
Explain LinkedList With Example
Explain Vector Class With Example
Explain Vector Class With Example
Generics in java with example
Behavior of generic objects
How can i pass generic class to a method in java
How to create a login system in jsp using mysql database?
How to create a login and logout system in jsp & servlet using mysql database?
How to connection a simple Java application with mysql database?
How to insert values in mysql databse usiong Java applications?
Perform insertion, retrieval, updatation and delete operations?
How to create a simple login system in java using mysql database?

PHP Login System Using MySql Database
PHP Complete Login System With Session And Logout Using MySql Database