where you have
// print form with values pre-filled
you should print that whole chunk of html from php with a print statement and not just ?> and <? later on if you get my drift. ie you are carrying the logical 'if' out of the php block - after you fix this see waht happens?
if (?) {
$big_block = "lots
and
lots of
html
code";
} else {
$big_block = "some more text";
}
then in the html
use
<? echo $bigblock; ?>