PHP form validation before submit using separate html and php files [closed]

I'm doing an assignment in which I am required to use separate html and php files but am having trouble understanding how to validate my forms input as all examples I've found have both html and php in one file. I've been following the example on w3schools:http://www.w3schools.com/php/php_form_validation.asp My w3_example.html:

     .error  ?> 

PHP Form Validation Example

* required field.

Name: *

E-mail: *

Website:

Comment:

Gender: Female Male *
My w3_example.php:
    else < $name = test_input($_POST["name"]); >if (empty($_POST["email"])) < $emailErr = "Email is required"; >else < $email = test_input($_POST["email"]); >if (empty($_POST["website"])) < $website = ""; >else < $website = test_input($_POST["website"]); >if (empty($_POST["comment"])) < $comment = ""; >else < $comment = test_input($_POST["comment"]); >if (empty($_POST["gender"])) < $genderErr = "Gender is required"; >else < $gender = test_input($_POST["gender"]); >> echo "

Your Input:

"; echo $name; echo "
"; echo $email; echo "
"; echo $website; echo "
"; echo $comment; echo "
"; echo $gender; ?>

I now get an "Call to undefined function test_input()" error on this line $name = test_input($_POST["name"]); in w3_example.php