12 Program to take input from different form element of HTML in PHP

Program:

2 Taking multiple type of input from user.php

<form action="get.php" method="post">

    <fieldset>

        <table align="center"> 

            <legend> Enter Details </legend>



            <tr>

                <td> Name: </td>

                <td> <input type="text" name="name"></td>

            </tr>



            <tr>

                <td> Password:</td>

                <td> <input type="password" name="password"> </td>

            </tr>





            <tr>

                <td> Gender:</td>

                <td> <input type="radio" name="gender" value="Male"> Male



                    <input type="radio" name="gender" value="Female"> Female</td>

            </tr>



            <tr>

                <td>Languages:</td>

                <td><input type="checkbox" name="lang[]" value="Hindi">  Hindi

                    <input type="checkbox" name="lang[]" value="Telugu"> Telugu

                    <input type="checkbox" name="lang[]" value="English"> English</td>

            </tr>



            <tr>

                <td>City:</td>

                <td><select name="city">

                        <option></option>

                        <option value="Hyderabad"> Hyderabad </option>

                        <option value="Delhi"> Delhi </option>

                        <option value="Chennai"> Chennai </option>

                    </select></td>

            </tr>



            <tr>

                <td> Address:</td>

                <td><textarea name="address"></textarea></td>

            </tr>



            <tr>

                <td align="center" colspan="2"> <input type=submit name="submit"> </td>

            </tr>



        </table>

    </fieldset>

</form>

get.php:
<?php

   

    $name = $_POST["name"];

    $pass = $_POST["password"];

    $gender = $_POST["gender"];

    $lang = $_POST["lang"];

    $city = $_POST["city"];

    $address = $_POST["address"];



    echo "Name is $name <br/>";

    echo "Password is $pass <br/>";

    echo "Gender is $gender <br/>";

    echo "Language is ";



    foreach($lang as $i)

    {

        echo " $i ";

    }



    echo "<br/>City is $city <br/>";

    echo "Address is $address <br/>";

   

?>


Output:

HTML Form Elements


After Submit Button Click:

HTML form elements in PHP

Previous
Next Post »