To answer your first question, you can accomplish this by first applying the server side validation show if server behavior to the input field and then taking the php code and place it in the value attribute of the input field, so your input field might look something like this:
<input id="firstname" name="firstname" type="text" value="<?php if($serverside) {echo "invalid";} else echo "First name"; ?>" onfocus="if (this.value == 'First name') this.value=''" onblur="if (this.value == '') this.value='First name'" />
for your second question, you can wrap the p tag with an if else statement:
<?php if(isset($_GET['sent']) && $_GET['sent'] == "true") { ?> <p id="confirm"> <strong>Thank you – your details have been processed. </strong></p><?php } else { ?>
<p>Sign up to our newsletter.</p>
<?php } ?>