SignUp form code in PHP

    Here we are going to learn how to design and code for signup . We are going to code in a simple way to get achieve our final result. In signup form we are going to learn and implement how to use "INSERT " query in mysql database. This query is used to insert data in database.

Syntax for INSERT query in database is as follows:

   " INSERT INTO table_name (column_name1, column_name2........) VALUES(value1,value2,.......) "

In below mentioned code table_name is "login" . It contain column with name as show in our html form. They are UserId, Password, Name, Address, MobileNo. We have 5 field in our mysql database.  

 Welcome to SignUp Form

UserId
Password
Name
Address
MobileNo


First we are going to design signup form . It is signup.html 

<!DOCTYPE html>
<html>
<head>
    <title>Signup form</title>
</head>
<body>
    <h1>Welcome to SignUp Form</h1>
    <form action="signup.php" method="POST">
        UserId<input type="text" name="UserId"><br>
        Password<input type="password" name="Password"><br>
        Name<input type="text" name="Name"><br>
        Address<input type="text" name="Address"><br>
        MobileNo<input type="text" name="MobileNo"><br>
        <input type="submit" name="signup" value="signup">
    </form>

</body>
</html>

Here is signup.php code to implement functionality in form

<!DOCTYPE html>
<html>
<head>
    <title>signup php page</title>
</head>
<body>
    <h1>signup data</h1>
<?php
$conn=new mysqli('localhost','root','','vibha');
$userid=mysqli_real_escape_string($conn,$_POST['UserId']);
$password=mysqli_real_escape_string($conn,$_POST['Password']);
$name=mysqli_real_escape_string($conn,$_POST['Name']);
$address=mysqli_real_escape_string($conn,$_POST['Address']);
$mobile=mysqli_real_escape_string($conn,$_POST['MobileNo']);

$query="INSERT INTO login (UserId,Password,Name,Address,MobileNo)
VALUES ('$userid','$password','$name','$address','$mobile')";

    $result=mysqli_query($conn,$query);
    echo "registered successfully!!!";
?>
</body>
</html>

Comments

Popular posts from this blog

Python