PHP Form Handling

Get the User Data through a form and display the data using a PHP Script

 
      <!-- demo on form handling using PHP code-->
      <!DOCTYPE html>
      <html lang="en">
      <head>
           <meta charset="UTF-8">
           <meta http-equiv="X-UA-Compatible" content="IE=edge">
           <meta name="viewport" content="width=device-width, initial-scale=1.0">
           <title>Form Handling using PHP</title>
      </head>
      <body>
           <form action="test.php" method="post" onsubmit="return true;">
            <label for="username">Enter your username</label>
            <input type="text" name="username" id="username" required><br>
            <label for="password">Enter your password</label>
            <input type="password" name="password" id="password"> <br>
            <label for="gender">Select your Gender</label> <br>
            <input type="radio" name="gender" value="Male">Male <br>
            <input type="radio" name="gender" value="Female">Female <br>
            <label for="subjects">Select your favourite subjects</label>
            <input type="checkbox" class="checkbox" name="sub[]" value="chemistry">Chemistry <br>
            <input type="checkbox" class="checkbox" name="sub[]" value="PHP">PHP <br>
            <input type="checkbox" class="checkbox" name="sub[]" value="English">English <br>
            <label for="country">Select your Country</label>
            <select name="country" id="country">
                <option value selected disabled required>--select an option below--</option>
                <option value="India">India</option>
                <option value="US">US</option>
            </select> <br>
            <label for="skill">Select your skill level</label>
            <input type="range" min="1" max="10" step="1" value="1" required name="skill" id="skill"><br>
            <input type="date" required name="inputdate">
            <input type="submit" value="submit" name="submit">
           </form>
          <?php
          if(isset($_POST['submit']))
          {
               $username = $_POST['username'];
               echo "The username is".$username;
               $password = $_POST['password'];
               echo "The password is".$password;
               $gender = $_POST['gender'];
               echo "The gender you have selected is".$gender;
               $subjects = $_POST['sub'];
               foreach($subjects as $value)
               {
                   echo $value;
               }
               $country = $_POST['country'];
               echo "The country you have selected is ".$country;
               $skill_level = $_POST['skill'];
               echo "The skill level you have selected is ".$skill_level;
               $joindate = $_POST['inputdate'];
               echo "The input date you have selected is ".$joindate;     
      
          }
         ?>
      </body>
      </html>
    
Output

Enter the Program title here

 
      copy and paste the code here
    
Output