html - Input Validation for PHP form -
i wonder why gender option reseting blank if click create button invalid input. must same value 1 selected before , after validation. see codes here: http://pastebin.com/gklews3h
for first name , gender ones working. thank helping im still learning.
while marius' answer right; fact variables case-sensitive, you'll either have use $gender
over, or $gender
on - can choose yourself, stick one. in php-standards, typically variable-names start lowercase letters, works either way (as long keep same name same variable).
you have redundancy in code (like else
-statements nothing). i'd suggest this. makes easier reading, , long use proper names variables, works too.
<select class="form-control" id="inputgender" name="gender" > <option></option> <option value="male" <?php if ($gender == 'male') echo 'selected'; ?>>male</option> <option value="female" <?php if ($gender == 'female') echo 'selected'; ?>>female</option> </select>
Comments
Post a Comment