I'm trying to create a nice php form that remembers what people enter in fields: text, radio, select, etc.
So I got this from a book:
Text:
<input type="text" name="ui_id" value="<?php if (isset($POST['ui_id'])) {
echo htmlentities($POST['ui_id'], ENT_COMPAT, 'UTF-8');} ?>" size="32" />
Radio:
<select name="tax_status">
<option value="0" <?php if (!(strcmp(0, htmlentities($POST['tax_status'], ENT_COMPAT, 'utf-8')))) {echo "SELECTED";} ?>>Single</option>
<option value="1" <?php if (!(strcmp(1, htmlentities($POST['tax_status'], ENT_COMPAT, 'utf-8')))) {echo "SELECTED";} ?>>Married</option>
</select>
Well I'm getting notices that these variables are undefined and the code seems rather unwieldy... is there a way to put this stuff into a function and then call something simpler in the from code itself? Is htmlentities a little over kill?
THanks