June 2005
Intermediate
720 pages
20h 6m
English
You’ve certainly come across sticky forms, even if you didn’t know that’s what they were called. A sticky form is simply a standard HTML form that remembers how you filled it out. This is a particularly nice feature for end users, especially if you are requiring them to resubmit a form (for instance, after filling it out incorrectly in the first place).
To preset what’s entered in a text box, use its value attribute:
<input type="text" name="city" size="20" → value="Innsbruck" />
To have PHP preset that value, print the appropriate variable:
<input type="text" name="city" size="20" → value="<?php echo $city; ?>" />
With this in mind, I’ll rewrite calculator.php so that it’s sticky.
1. | Open calculator.php ... |
Read now
Unlock full access