Sunday 7 January 2018

How To Create Registration Form In PHP?

Step 1:

Start the XAMPP server
Click on the "Start" button next to "Apache" to start your Apache Web server and also start "MySQL"

Step 2:

Create Index.html

<!doctype html>
<html lang="en:US">
<head>
<meta charset="UTF-8">
<title>Registration Form</title>
</head>
<body>

<form method="Post" action="reg.php">

<fieldset>
<h2>Enquiry Form</h2>
 UserName: <input type="text" placeholder="Enter Username" name="Uname"><br><br>

Age: <input type ="number" placeholder="Enter Age" name="Uage"><br><br>

Address:<textarea name="Add" rows="3" cols="30"></textarea><br><br>

Gender:
<input type ="radio" name="gender" value="Male" checked>Male
<input type ="radio" name="gender" value="Female">Female</br>

Qualification:
<select name="Qualification">
<option value ="BE">BE</option>
<option value ="BTech">BTech</option>
<option value ="MCA">MCA</option>
<option value ="MA">MA</option>
<option value ="MCS">MCS</option>
<option value ="Other">Other</option>
</select></br>

Hobbies:
<input type="checkbox" name="check_list[]" value="Dancing"> Dancing
<input type="checkbox" name="check_list[]"value="Singing">Singing
<input type="checkbox" name="check_list[]" value="Netsurfing">Netsurfing <br><br>

<input type="submit" name="submitbtn" value="Register"/>

</fieldset>
</form>
</body>
</html>

Step 3: 

Create reg.php

    <?php
    if(isset($_POST['submitbtn']))
    {
        $Name= $_POST['Uname'];
        $Age = $_POST['Uage'];
        $Address = $_POST['Add'];
        $Gender=$_POST['gender'];
        $Qualification=$_POST['Qualification'];
        $Hobbies=$_POST['check_list'];
                       
       echo "Information Details:</br>";
             
       echo "UserName:$Name</br>";
             
       echo "Age:$Age</br>";
             
      echo "Address:$Address</br>";
             
       echo "Gender:";
        if($Gender == "Male")
              {    
       echo("Male</br>");
              }      
      else
              {
     echo("Female</br>");
              }
            
echo "Qualification:$Qualification</br>";


echo "Hobbies";
if(!empty($Hobbies) )
{
foreach($_POST['check_list'] as $selected)
{
echo "<p>".$selected ."</p>";
}
}
else{
echo "<i>Please Select At least One Option.</i>";
}

}
?>
Step 4 :

Save both the file(Index.html,reg.php) in htdocs under  xampp  server in c:drive.

Step  5:

Open the browser (chrome) and type it
localhost/ Index
.html

Registration Form

UserName: 

Age:      14

Address:


Gender:
Male Female

Qualification:
      

Hobbies:
 Dancing Singing Netsurfing


After clicking on Register button you can get the following output

Information Details:
UserName:Harish
Age:14
Address:Pune Viman nagar
Gender:Male
Qualification:MCA
Hobbies:Dancing
,Netsurfing



No comments:

Post a Comment

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...