I'm trying to create a full validation page for an input (sql insert) form.
What I've typically been doing are the following to preserve the values already input on the page in case one piece of validation fails (in which case the user is returned to the form to correct it with an error shown).
echo 'value=" ';
if(isset($_POST['NewGameName'])){
echo $_POST['NewGameName'];
} // for text-fields
echo '<option value="'.$i.'" ';
if(isset($_POST['Score'])){
if($i == $_POST['Score']){
echo'selected="selected"';
}
}
echo '>'.$i.'</option>'; // for dropdowns
But I can't seem to find a way to preserve the file location if the page is refreshed. Is there a way to do this? I've read that it's always cleared for security reasons which would be annoying but if it's the standard I guess people are used to it.
you could create a hidden field to store the file name and change the name through javascript by using onchange event on the actual file field. as soon as file name changes you could update the hidden field value. you get the hidden field value in the post variable and use this variable to refresh the value of the file field