OK well the first section would be much cleaner as
CODE
if ($_POST['submit']) {
$valid = false;
if (empty($_POST['firstname']) ) {
$firstname_error = 'You did not enter your first name';
}
else if (empty($_POST['lastname'])) {
$lastname_error = 'You did not enter your last name';
}
else if (empty($_POST['company'])) {
$company_error = 'You did not enter your company';
}
else if (empty($_POST['address1'])) {
$address1_error = 'You did not enter your address';
}
else if (empty($_POST['city'])) {
$city_error = 'You did not enter your city';
}
else if (empty($_POST['state'])) {
$state_error = 'You did not enter your state';
}
else if (empty($_POST['email'])) {
$email_error = 'You did not enter your e-mail address';
}
else {
$valid = true;
}
See, alot less code (you'll have to remember to change the variables in the form at the bottom); but even that is a little messy.
However empty() isn't a fantastic check as there is nothing stopping me from simply entering loads of white space.
So what you'll need is something like
CODE
foreach ($_POST as $key => $var) {
$_POST[$key] = trim($var);
}
but take a look at array_walk as that would be better.
Also for fields like "state" you want want to ensure that it is from a valid list of states and you might want to use regex to check that the format of the email address is at least valid