The if scope is just a simple validation which means that every field should not be empty.
If any field not input, the script will quit and show an error message “Invalid data”.(die will stop the script, and the script will not be continued anymore)
For more complex validation, you should change this scope.
For example, to check the email, you may use regular expression; you may also limit the string length of first name and last name.
I’ve created a gist here: https://gist.github.com/f86c0424202c03be8d79
//validate first name
die('First name too long');
//validate last name
die('Last name too long');
die('Invalid email address');