Forms

HTML forms are used to collect information from a user.

At Advanced Higher, you need to be able to create and understand forms that use:

  • <form>
  • <input>
  • <select>
  • <textarea>
  • name
  • value
  • action
  • method

Example

<form action="process.php" method="post"> 
    Name: 
    <input type="text" name="name"> 

    <input type="submit" value="Submit"> 
</form>

Action

  • The action attribute tells the browser which file should process the form data when the form is submitted.
  • <form action=”process.php”>
  • In this example, the form data is sent to process.php.

Method

  • The method attribute controls how the form data is sent.
  • <form action=”process.php” method=”post”>
  • The two methods are:
    • GET — the submitted data is visible to the user
    • POST — the submitted data is hidden from the user