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.
I think you have 2 options.
is to use Ajax for validation. This way you don't leave the form with the filepath.
Use javascript after the validation to go back in history
history.go(-1)
to the previous screen. I think when using history, the form entries are preserved.