1 Minute HTML CSS Part 17 – Basic Forms

BASIC HTML FORM

<form target="_blank" action="dummy.php" method="post">
  <input type="text" name="username">
  <input type="submit" value="Submit">
</form>
  • <form> The HTML form.
  • <input> Form fields.
    • type Field type. For now, a simple text field and submit button. Will go through more in next few chapters.
    • name Name of the field.
    • value On submit button, this is the button text. If set on text field, this is the default text.

 

HTML FORM ATTRIBUTES

  • target Where to submit the form.
    • _self In same window, the default if not specified.
    • _blank In a new tab.
  • action Submit to which script. Default is the current page.
  • method Submission method.
    • get Show the submitted form data in the URL. The default.
    • post Hide the submitted form data.

 

FORM SUBMISSION

Take note of how form submission work.

  • get Form data will be appended to the URL. Example – http://site.com/submit.php?username=Jon&gender=Male
  • post Form data is hidden, but can still be retrieved on the server-side. PHP example – echo $_POST["username"];

Leave a Comment

Your email address will not be published. Required fields are marked *