Create a Registration Form Using Form Element

Creating User registration form by using Form elements:
 

 HTML Code:


<html>
<head>
<title>User Registration</title>
</head>
<body>
<form action="FormInfo.php" method="post">
<table><caption>Registration form</caption>
<tr><td>Name:-</td>
<td><input name="txtname" type="text" size="30" maxlength="30" ></td></tr>
<tr><td>Branch:-</td><td><input name="txtbranch" type="text"></td></tr>
<tr><td>Select Gender:-</td>
<td><input name="RGender" type="radio" value="Male">Male&nbsp;
<input name="RGender" type="radio" value="Female">Female</td></tr>
<tr><td> City :</td><td>
<select name="list">
<option value="Bhavnagar">Bhavnagar</option>
<option value="Ahemdabad">Ahemdabad</option>
<option value="Bombay">Bombay</option>
<option value="Baroda">Baroda</option>

</select>
</td></tr>
<tr> <td>Specialization</td> <td>
<input name="sub1" type="checkbox" value="Hardware">Hardware &nbsp;
<input name="sub2" type="checkbox" value="Software">Software &nbsp;
<input name="sub3" type="checkbox" value="Networking">Networking
</td></tr>
<tr><td><div align="left">Address:-</div></td><td><textarea name="txtAdrs"
cols="40" rows="5"></textarea></td></tr>
<tr><td>Pincode:-</td><td><input name="txtpin" type="text"></td></tr>
<tr><td><input name="submit " type="submit" value="Submit Form"></td>
<td><input name="Reset" type="reset" value="Reset"></td></tr>
</table></form></body></html>


Ø Now, the above user registration form is created by using HTML. To display or to submit all the form information we have to use $_GET and
$_POST variable.
Ø The predefined $_GET variable is used to collect values in a form with method="get". The predefined $_POST variable is used to collect values from a form sent with method="post".
Ø Instead of using $_GET or $_POST we can also use $_REQUEST variable.
The  predefined  $_REQUEST  variable  contains  the  contents  of  both
$_GET and $_POST.
Ø The $_REQUEST variable can be used to collect form data sent with
both the GET and POST methods.
Ø Below is the PHP code to display all the submitted data in new page by using $_REQUEST.



PHP Code:  FormInfo.php :-


<html>
<head><title>User information</title></head>
<body><table width="130">
<caption>User Information</caption>
<tr><td>Name:-</td>
<td><?php

if (isset($_REQUEST['txtname']))
echo $_REQUEST['txtname'];  // display the name
?></td></tr>
<tr><td>Branch:-</td>                                 
<td><?php
if (isset($_REQUEST['txtbranch']))
echo $_REQUEST['txtbranch']; // display the branch name
?></td></tr><tr><td>Gender:-</td>
<tr>
<td>City:-</td>
<td><?php
if (isset($_REQUEST['list']))
echo $_REQUEST['list']; // display selected city name
?>
</td>
</tr>
<td><?php
if (isset($_REQUEST['RGender']))
echo $_REQUEST['RGender'];  //display the selected gender
?></td></tr>



<tr><td>Specialization:-</td>
<td> <?php
if (isset($_REQUEST['sub1'])) echo " ".$_REQUEST['sub1'];              if (isset($_REQUEST['sub2'])) echo " ".$_REQUEST['sub2']; if (isset($_REQUEST['sub3']))
echo " ".$_REQUEST['sub3'];
?></td></tr>                                                      
<tr><td>Address:-</td>

<td><?php if (isset($_REQUEST['txtAdrs']))
echo $_REQUEST['txtAdrs']; // display the address
?></td></tr>
<tr><td>Pincode:-</td>
<td><?php
if (isset($_REQUEST['txtpin']))
echo $_REQUEST['txtpin']; //display the pincode
?></td></tr>
</table>
</body>
</html>

Create a Registration Form Using Form Element Create a Registration Form Using Form Element Reviewed by Unknown on 21:02:00 Rating: 5

No comments:

Powered by Blogger.