Well you kind of have me confused how you posted your code. Which code is mainform.php and which order.php?
Also, its better to use the isset() function to test if variables are empty/nonempty. So a better way would be to do
PHP Code:
if (!isset($name)) {
include "mailform.php";
echo "Please write your contact name\n";
}
And as a side note, I usually like to do form validation in JavaScript, it saves a lot submissions/checks/redirects.