Problems with new tutorial

I’m very new to php. But I have set up a form thing before.

Anyway, I downloaded the zipped file from Kirupa’s new tutorial and uploaded everything as a test after changing the script to email the info to my email. Welp, it does email me, but if I leave the text fields empty, it says that there’s an error onl ine 18 I believe of the php script. THis is what Kirupa was talking about as the looping thing. AND it still send a totally blank email!

How do I fix it so it doesn’t show the error but doesn’t send the email if it’s not filled out correctly? Basically, I want to redirect the users to another page if they dont fill it out right. You get the idea.