|
home—lects—exams—hws
breeze (snow day)
From PHP Visual Quickstart Guide by Larry Ullman
Originally based on notes by Jack Davis (jcdavis@radford.edu)
<input type='checkbox' name='cb1' value='milk' id='cbOne' checked='checked' /> |
<input type='text' name='txt1' size='10' maxlength='8' id='txtone' /> |
<input type='radio' name='age' value='over50' /> <br/> <input type='radio' name='age' value='30to50' /> <br/> <input type='radio' name='age' value='under30' /> <br/> |
<textarea name='comments' rows='3' cols='30'> Initial Contents </textarea> |
(I'm not really sure why text areas are different from
from checkboxes/radio-buttons/text-fields1.
It'd seem more sensible to either have a single tag
<select name='title'> <option value = 'mr'>Mr.</option> <option value = 'ms'>Ms.</option> <option value = 'mrs'>Mrs.</option> <option value = 'miss'>Miss</option> </select> |
<input type='submit' value='Submit Data to Server' /> |
<input type='reset' value='Clear Form' /> |
Q: But how is information communicated from a web form (pure html) to a php program?
A: When you click 'submit', the HTML makes a page-request to the page specified by the form's "action" attribute.
(Presumably it's a php page.)
The page-request incudes extra information about what html input fields had been selected, etc..
The server gets that request and invokes the php file as normal, but it also
pre-initializes an array of values for the program — and it fills that array with
the extra information contained in the page-request.
As we saw,
we can combine values (to use as an argument to
See also various error functions.
1
Note that everything the HTML designers bundled together
under the
home—lects—exams—hws
breeze (snow day)
©2011, Ian Barland, Radford University Last modified 2011.Sep.16 (Fri) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |