Since PHP works server side, the only way to know if the user has or hasn't entered info into those 2 fields is to check after the form has been submited. You can perform a check like
if(empty($_POST['name']))
{//if true, invoke error handler
header("Location: error.php?e=1");
exit;
}
if(empty($_POST['Surname']))
{//if true, invoke error handler
header("Location: error.php?e=2");
exit;
}
To check whether the user has filled out the form correctly before submission, you need to use javascript. Javascript is run client side and can be turned off by the user, so don't soley rely on a js validation.
I use both, serverside validation that throws an error on an error page, and javascript to give the specific errors on the page before the form is submitted.
with javascript turned on and a good validation script, the javascript should catch all the errors and the serverside validation always sees good data. if javascript is turned off, then the serverside validation is the only defense.
here are some good javascript form validation pages
Simple Tricks for More Usable Forms
Javascript form validation – doing it right