A form is an interface between your web page's viewers and a script of some kind. The script may be browser-side like Javascript or server-side like PHP and Perl. The form is used to collect information from the viewer. The script processes the information. The script may or may not be on the same web page as the form but without the script, the form doesn't process anything. All forms start with
<form>
and end with
</form>
<form action="http://www.google.com/search" method="get">
<input type="text" name="q" size="25" maxlength="255" value="">
<input type="submit" name="btnG" value="Google Search">
</form>
<form target="display">
</form>
Get will append the form data to the URL. You can see an example when you use Google. Post will send the form data in a way that is not visible to the user. Which one you use depends on the nature of your form.
Having the form data appended to the URL allows you to bookmark the results of a form or post or email it to someone else. If you want to share the data, that is OK but if the form is a login, the username and password will be on the end of the URL for all of the world to see. If you click a link on a page that has the username and password exposed, the target page can get them by checking the referals to that page.
A URL has a limit to it's length. If you exceed that length, the data on the end will be ignored. For something like a search engine, the data will usually fit on a URL so you can use get but if your form is editing a webpage, the data may be hundreds of characters long so in that case, you should use post.
Some attributes that form elements may have include:
<input type="text" disabled value="disabled" /><input type="text" readonly value="readonly" />
<select>
<option>1</option>
<option selected>2</option>
<option>3</option>
</select>
|
|
|