function strip( $str )
// Strip all spaces and hypens from phone numbers
{
$stripped = str_replace( " ", "", $str );
$stripped = str_replace( "-", "", $stripped );
return ($stripped);
}
// only validate form when form is submitted
if(isset($submit_button)){
$error_msg='';
// Overview Section
if ($Purpose=='other' and trim($Purpose_Other)=='')
$error_msg.="Please specify the purpose of your website - you have selected 'Other'.
";
if(trim($Description)=='') {
$error_msg.="Please enter a description of your organisation.
";
}
if ($Work_Type=='other' and trim($Work_Other)=='')
$error_msg.="Please specify the type of work required - you have selected 'Other'.
"; // if no error messages, proceed to other processing
// Content Section
if ($Num_product_pages!='' and $Products_Pages!='yes')
$Products_Pages='yes';
if ($Num_services_pages!='' and $Services_Pages!='yes')
$Services_Pages='yes';
if ($Num_portfolio_pages!='' and $Portfolio_Pages!='yes')
$Portfolio_Pages='yes';
if ($Num_testimonials!='' and $Testimonials!='yes')
$Testimonials='yes';
if ($Num_press_releases!='' and $Press_Releases!='yes')
$Press_Releases='yes';
if ($Products_Pages=='yes' and $Num_product_pages=='')
$error_msg.="Please specify the number of product pages you require (approximately).
";
if ($Services_Pages=='yes' and $Num_services_pages=='')
$error_msg.="Please specify the number of services pages you require (approximately).
";
if ($Portfolio_Pages=='yes' and $Num_portfolio_pages=='')
$error_msg.="Please specify the number of portfolio pages you require (approximately).
";
if ($Testimonials=='yes' and $Num_testimonials=='')
$error_msg.="Please specify the number of testimonials you have (approximately).
";
if ($Press_Releases=='yes' and $Num_press_releases=='')
$error_msg.="Please specify the number of press releases you have (approximately).
";
if ($Other_Pages=='yes' and trim($List_Other_Pages)=='')
$error_msg.="Please list the other pages you require.
";
if ($Other_Features=='yes' and trim($List_Other_Features)=='')
$error_msg.="Please list the other features you require.
";
// Technical Details Section
if($Already_Own=='yes' and trim($Domain_owned)=='') {
$error_msg.="Please enter the web address you own.
";
}
else if($Already_Own=='no' and trim($Domain_wanted)=='') {
$error_msg.="Please enter the web address you would like.
";
}
// Contact Section
if ($Source=='other' and trim($Source_Other)=='')
$error_msg.="Please specify how you heard about us - you have selected 'Other'.
";
if(trim($Contact_Name)=='') {
$error_msg.="Please enter a contact name
";
}
if(trim($Phone)=='') {
$error_msg.="Please enter a phone number
";
} else {
// check if phone number is valid
$sphone = strip($Phone);
if (!ereg( "^[1-9][0-9]{7}$", $sphone)) $error_msg.="Please enter a valid phone number
";
}
if(trim($Mobile)!='') {
// check if mobile phone number is valid
$smobile = strip($Mobile);
if (!ereg( "^0[0-9]{9}$", $smobile)) $error_msg.="Please enter a valid mobile phone number
";
}
if (trim($Email)=='') {
$error_msg.="Please enter an email address
";
} else {
// check if Email is a valid address in this format username@domain.com
if(!ereg("[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-.]?[0-9a-zA-Z])*\\.[a-zA-Z]", $Email)) $error_msg.="Please enter a valid Email address
";
}
// if no error messages, proceed to other processing
if($error_msg=='')
{
$subject = "NetSavvy Online Quotation Request";
$headers = "From: $Email\r\n";
$message = "A request for a quotation has been received via the website:\n";
foreach ($HTTP_POST_VARS as $key => $value)
if ($key != "submit_button")
$message .= "$key:\t\t$value\r\n";
$ok = mail("annettes@ee.unsw.edu.au", $subject, $message, $headers);
if (!$ok)
echo "Your request could not be sent. Please try again";
else
header("location: thanks.htm");
}
}
?>
$error_msg"; } ?>