Thursday, October 30, 2014

Create form using text box, check box, radio button, select, submit button. And display user inserted value in new PHP page (e.g. student registration/inventory/library form).



Code: registration.html

<html>
          <head>
          <title>registration from</title>
          </head>
         
          <body>
          <form method="get" action="form2.php">
                   <table align="center" height="100%" width="100%" border="2">
                   <tr height="20%">
<td colspan="3"><center><h1><b>Registration form</b></h1></center></td>
                   </tr>
                   <tr height="60%">
                             <td width="20%">&nbsp;</td>
                             <td width="60%">
                                      <table align="center" height="100%">
                                                <th>name:</th>
                                                <td>
                                                          <input type="text" name="txt_name">
                                                </td>
                                      </tr>
                  
                                      <tr>
                                                <th>User name:</th>
                                                <td>
                                                          <input type="text" name="txt_uname">
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Password:</th>
                                                <td>
                                                          <input type="password" name="pwd">
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Hobby:</th>
                                                <td>
<input type="checkbox" name= "check_list[]" value="reading">reading
<input type="checkbox" name= "check_list[]" value="writing">writing
<input type="checkbox" name= "check_list[]" value="playing">playing
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>City:</th>
                                                <td>
                                                           <select name="dd_city">
<option value="Rajkot">Rajkot </option>
<option value="Baroda">Baroda </option>
<option value="Mumbai">Mumbai </option>
                                                                    <option value="Pune">Pune                                                                     </option>
                                                          </select>
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Gender:</th>
                                                <td>
                                                          <input type="radio" name="rb" value=                                                     "male">Male<br>
                                                          <input type="radio" name="rb" value=                                                     "female">Female
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Phone no:</th>
                                                <td>
                                                          <input type="text" name="txt_phone">
                                                </td>
                                      </tr>
                                      <tr>
                                                <th>Email:</th>
                                                <td>
                                                          <input type="text" name="txt_mail">
                                                </td>
                                      </tr>
                                      <tr>
                                                <td align="center">
                                                          <input type="submit" value="submit">
                                                </td>
                                                <td>
                                                          <input type="reset" value="reset">
                                                </td>
                                      </tr>
                             </td>
                             </table>
                             <td width="20%">&nbsp;</td>
                   </tr>
                   <tr height="20%">
<td colspan="3"><center><h2><b><i>Prepered By:Harshiv Parsana</i></b></h2></center></td>
                   </tr>
          </table>

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


Code: form2.php

<html>
          <head>
                   <title>harshiv</title>
          </head>
          <body>
          <form action="form2.php" method="get">
          <table border='3' height=100% width=100% align="center" style="font-   size:x-large">
                   <tr>
<td colspan="3" height=20%><center><h1><b>Registration form</b></h1></center></td>

                   </tr>
                   <tr>
                             <td width=20%>&nbsp</td>
                             <td align="justify">
                                      <?php

                                                echo "name:";
                                                $name=$_GET["txt_name"];
                                                echo " $name"." </br>";

                                                echo "Username::";
                                                $uname=$_GET["txt_uname"];
                                                echo "$uname"." </br>";
         
                                                echo "Password::";
                                                $pwd=$_GET["pwd"];
                                                echo "$pwd"." </br>";

                                                echo "hobby:";
                                                if(isset($_GET['check_list'])){
                                                if(!empty($_GET['check_list'])){

                                                foreach($_GET['check_list'] as $selected){
                                                echo $selected."</br>";
                                                }
                                                }
                                                }
                                                echo "city:";
                                                $city=$_GET["dd_city"];
                                                echo "$city"." </br>";

                                                echo "gender:";
                                                echo $_GET['rb']."</br>"; 

                                                echo "Phone no:";
                                                $Phoneno=$_GET["txt_phone"];
                                                echo "$Phoneno"." </br>";

                                                echo "Email:";
                                                $email=$_GET["txt_mail"];
                                                echo "$email"." </br>";

                                      ?>

                             </td>
                             <td width=20%>&nbsp</td>
                   </tr>
                   <tr>
<td colspan="3" height=20%><center><h2><b><i>Prepered By:Harshiv Parsana</i></b></h2></center></td>

                   </tr>
          </table>
          </form>
          </body>
</html>      



Output:


No comments:

Post a Comment