All form processing must be applied to the forms action page.
if the action of the form is to post to another page, then the validation server behavior should go on that other page.
the syntax error at line 4:
if () {
is because no trigger was selected. it should be something like this for any form post:
if($_SERVER["REQUEST_METHOD"] == "POST") {