Contact form tutorial validation

First of all contact form tutorial is really nice, but I have a couple of questions. The tutorial assumes that if you’ve pressed submit button your information is good to go. I would like to validate a couple of fields (for example name and email) if they’re not set you would get an error message (i.e you forget to enter a valid e-mail) and link back to the previous page. So any information isn’t sent before certain fields are filled correctly.

I would like to use PHP for this because not everyone has their Javascript turned on an it’s more secure to check your information serverside, not user agent side.

Any help would be really appriciated,

Thanks in advance!