How to get data from a form

Sample <form> Tag

    <form id="myForm" name="MyForm" action="process_data.php" method="POST">
    

The HTML for three types of fields

      <input type="text" id="user_name" name="user_name" value="harris" />
      <input type="password" id="user_password" name="user_password" />
      <input type="hidden" id="action" name="action" value="login" />
      

The URL when using the GET method

      process_data.php?user_name=rharris&password=s3cr3t72&action=login
      

The URL when using the POST method

      process_data.php

The PHP for the POST method

      <?php
      $user_name     = filter_input(INPUT_POST, 'user_name');
      $user_password = filter_input(INPUT_POST, 'user_password');
      $action        = filter_input(INPUT_POST, 'action');
      ?>
      

Back