many ways to do this.
this is how i would do it:
<?php
$valid_email = false;
$valid_first = false;
$valid_last = false;
$valid_org = false;
$errors = array();
if(isset($_POST['submitform']) && $_POST['submitform']==1) {
if(isset($_POST['email']) && eregi("^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$", $_POST['email'])) {
$valid_email = true;
} else {
array_push($errors, "You must submit a valid E-Mail.");
}
if ($_POST['firstname'])!="") {
$valid_first = true;
} else {
array_push($errors, "You must enter your first name.");
}
if ($_POST['lastname'])!="") {
$valid_last = true;
} else {
array_push($errors, "You must enter your last name.");
}
if ($_POST['organization'])!="") {
$valid_org = true;
} else {
array_push($errors, "You must enter your organization.");
}
if ($valid_email && $valid_first && $valid_last && $valid_org) {
$to = "info@gttgrp.com";
$subject = "GTT FORM SUBMISSION";
$headers = "From: ".$_POST['email'];
$date = date("r");
$message = "Form submission sent from 'Subscribe' at ".$date."\n\n";
$message .= "Salutation : ".$_POST['salutation']."\n";
$message .= "First Name : ".$_POST['firstname']."\n";
$message .= "Last Name : ".$_POST['lastname']."\n";
$message .= "Company : ".$_POST['organization']."\n";
$message .= "Title : ".$_POST['title']."\n\n";
$message .= "Country : ".$_POST['country']."\n\n";
$message .= "Phone : ".$_POST['phone']."\n";
$message .= "Email : ".$_POST['email']."\n\n";
if(isset($_POST['addtonetwork']) && $_POST['addtonetwork']=='yes') {
$message .= "YES - Add to network.\n\n";
} else {
$message .= "NO - Do not add to network.\n\n";
}
if(mail($to, $subject, $message, $headers)) {
include("includes/thankyou.php");
} else {
global $error;
$error = "Mail could not be sent!";
include("includes/form_subscribe.php");
}
} else {
global $error;
$error = implode("<br />", $errors);
include("includes/form_subscribe.php");
}
} else {
include("includes/form_subscribe.php");
}
?>