L03 Form
L03 Form
Web Form
Joseph Tonien
Form
● HTML forms are used to collect user input.
● When user clicks a submit button, user input will be sent to the server to
process
Form - type text
<form ...>
First name:<br />
<input type="text" name="firstname" size="30"><br />
Last name:<br />
<input type="text" name="lastname" size="30"><br />
...
</form>
Form - type password
<form ...>
Username:<br />
<input type="text" name="username" size="30"><br />
Password:<br />
<input type="password" name="password" size="30"><br />
...
</form>
Form - type checkbox
This is the value that sent to server
<form ...>
Choose journals to subscribe:<br />
<input type="checkbox" name="journal" value="AMM">American
Mathematical Monthly<br />
<input type="checkbox" name="journal" value="CMJ">College
Mathematics Journal<br />
<input type="checkbox" name="journal" value="MM">Mathematics
Magazine<br />
...
</form>
This is the value that get displayed
Form - type radio
This is the value that sent to server
<form ...>
Select student type:<br />
<input type="radio" name="studentType" value="u">Undergraduate
<input type="radio" name="studentType" value="p">Postgraduate
<input type="radio" name="studentType" value="other">Other
...
</form>
<form ...>
Select day:<br />
<select name="day">
<option value="mon">Monday</option>
<option value="tue">Tuesday</option>
<option value="wed">Wednesday</option>
<option value="thu">Thursday</option>
<option value="fri">Friday</option>
</select>
...
</form>
This is the value that get displayed
Form - select multiple
<form ...>
Select day:<br />
<select name="day" multiple>
<option value="mon">Monday</option>
<option value="tue">Tuesday</option>
<option value="wed">Wednesday</option>
<option value="thu">Thursday</option>
<option value="fri">Friday</option>
</select>
...
</form>
Form - textarea
<form ...>
Enter your comment:<br />
<textarea name="comment" rows="5" cols="30">
</textarea>
...
</form>
Form - submit this is the program in the server that processes the form
</form>
Form method
<form action="handle_login" method="post">
method="get" method="post"
Visibility Data is visible in the URL Data is not displayed in the URL
Security get is less secure compared to post because data sent in part of
the URL.
Never use get when sending passwords or other sensitive
information.
method="get" method="post"
</form>
<form ...>
First name:<br />
<input type="text" name="firstname" size="30"><br />
Last name:<br />
<input type="text" name="lastname" size="30"><br />
</form> file:///D:/demo/handle_login?
</body> journal=AMM&
</html> journal=CMJ&
studentType=other&
day=mon&
day=wed
Examples
Google search
http://www.uow.edu.au/~dong/w3/example/form/google-search.html
Google translation
http://www.uow.edu.au/~dong/w3/example/form/google-
translation.html
How can we find out the parameters for Google search and Google translation?
References
http://www.w3schools.com/html