PHP HTML Forms

Description

An HTML form is a collection of HTML elements embedded within a page. By adding different types of elements, you can create different form fields, such as text fields, pull-down menus, checkboxes, and so on.

Example

All Web forms start with an opening <form> tag, and end with a closing </form> tag:


<form action="myscript.php" method="POST">  
     <!-- Contents of the form go here -->  
</form>  

Form attributes

There are two attributes within the opening <form> tag:

  • action - tells the browser where to send the form data. This should either be an absolute URL or a relative URL.
  • method - tells the browser how to send the form data. You can use two methods: GET is for sending small amounts of data and makes it easy for the user to resubmit the form, and POST can send much larger amounts of form data.

Example 2


<form action="someform.php" method="post">
  Name: <input type="text" name="Name" value="Jim" /><br />
  Password: <input type="password" name="Password" /><br />
  Age: <input type="text" name="Age" /><br />
  <input type="submit" />
</form>/*from   ww  w.jav a 2s  . c o m*/




















Home »
  PHP Tutorial »
    Form »




PHP Form
Form Demo