|
home—lects—hws
D2L—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.,
as part of the http request.
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.
1
Note that everything the HTML designers bundled together
under the
2 idempotent is not quite the same as having no side-effect: For example, if you add-to-shopping-cart-unless-item-already-there, you can change state but still be idempotent. ↩
3
Well, “irrelevant” state-change is okay:
you can update log files and update cookie-timestamps,
w/o violating the spirit of a
home—lects—hws
D2L—breeze (snow day)
©2014, Ian Barland, Radford University Last modified 2014.Feb.10 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |