You actually need a strategy that caters to the retention and display of data whatever the circumstances. This is easily achieved through session vars.
1 set up empty session vars for form fields
2 check for form data and populate session vars
3 or check for existing data and populate from db
4 set value of form elements to these vars so that:
a) when empty they result in blank form fields
b) when populated from db the form displays them
c) when populated from post vars they in turn are displayed
session_start();
// set session data function
function set_sess($array) {
foreach ($array as $key=>$val) {
$_SESSION[$key] = $val;
}
}
// set up empty form
$formary = array('field1'=>'', 'field2'=>'', 'field3'=>'');
set_sess($formary);
// populate from db
set_sess($row);
// populate from form input
set_sess($_POST);
// display form
echo '<form>
<input type="text" name="field1" value="' . $_SESSION['field1'] . '" />
<input type="text" name="field2" value="' . $_SESSION['field2'] . '" />
<input type="text" name="field3" value="' . $_SESSION['field3'] . '" />
</form>';
I'll leave it to you to code the test for form submit, db query, etc.