This forum is slowly becoming my new best friend... 🙂
This is probably one of the most simplest of tasks, but apparently I can't figure it out. On error I want my form to remember the values that the visitor typed. The drop down menu I have remembers it's status, the rest of the fields don't.
Can someone provide an example?
Here is the code that displays the form:
<p class="styleinfo">Please fill out the form below to register.</p>
<form action='http://localhost/testform1.php' method='POST'>
<div id='field'><label for='user_name'>Desired User Name</label>
<input id='user_name' name='user_name' type='text' value=''
size='40%' maxlength='65' /></div>
<div id='field'><label for='password'>Choose a password</label>
<input id='password' name='password' type='password' value=''
size='40%' maxlength='65' /></div>
<div id='field'><label for='first_name'>First Name</label>
<input id='first_name' name='first_name' type='text' value=''
size='40%' maxlength='65' /></div>
<div id='field'><label for='last_name'>Last Name</label>
<input id='last_name' name='last_name' type='text' value=''
size='40%' maxlength='65' /></div>
<div id='field'><label for='address'>Street Address</label>
<input id='address' name='address' type='text' value=''
size='40%' maxlength='65' /></div>
<div id='field'><label for='address2'>Address Line 2</label>
<input id='address2' name='address2' type='text' value=''
size='40%' maxlength='65' /></div>
<div id='field'><label for='city'>City</label>
<input id='city' name='city' type='text' value=''
size='40%' maxlength='65' /></div>
<div class="field"><label for='state'>State</label>
<select name="state">
<?php
foreach ($states as $state)
{
$sel = '';
if (isset($_POST['state']) AND $_POST['state'] == $state)
{
$sel = 'selected="selected"';
}
echo '<option value="'.$state.'" '.$sel.'>'.$state.'</option>';
}
?>
</select> </div>
<div id='field'><label for='zip'>Zip Code</label>
<input id='zip' name='zip' type='text' value=''
size='40%' maxlength='65' /></div>
<div id='field'><label for='email'>Email</label>
<input id='email' name='email' type='text' value=''
size='40%' maxlength='65' /></div>
<div id='field'><label for='phone'>Phone</label>
<input id='phone' name='phone' type='text' value=''
size='40%' maxlength='65' /></div>
<div id='submit'>
<input type='hidden' name='submitted' value='yes'>
<input type='submit' name='register' value='Register'></div>
</form>
</tr>
</table>
</div>
</body>
</html>