| Inquiry Form |
|
$show_form=true;
class MyValidator extends CustomValidator
{
function DoValidate(&$formars,&$error_hash)
{
if(stristr($formars['address'],'http://'))
{
$error_hash['address']="No URLs allowed in address";
return false;
}
if(stristr($formars['address'],'@'))
{
$error_hash['address']="No Email Address allowed in address";
return false;
}
if(stristr($formars['query'],'http://'))
{
$error_hash['query']="No URLs allowed in query";
return false;
}
if(stristr($formars['query'],'@'))
{
$error_hash['query']="No Email Address allowed in query";
return false;
}
return true;
}
}
if($_GET['Submit'] == 'Submit')
{
// if($_POST['img_code']==$_SESSION['security_code'])
// {
$_SESSION['name'] =$_POST['name'];
$_SESSION['profession'] =$_POST['profession'];
$_SESSION['organization'] =$_POST['organization'];
$_SESSION['address'] =$_POST['address'];
$_SESSION['city'] =$_POST['city'];
$_SESSION['state'] =$_POST['state'];
$_SESSION['country'] =$_POST['country'];
$_SESSION['zip'] =$_POST['zip'];
$_SESSION['phone'] =$_POST['phone'];
$_SESSION['email'] =$_POST['email'];
$_SESSION['fax'] =$_POST['fax'];
$_SESSION['query'] =$_POST['query'];
// VERIRY INPUT DATE
$validator = new FormValidator();
$validator->addValidation("name","req","Please fill in Name");
$validator->addValidation("address","req","Please fill in Address");
$validator->addValidation("phone","req","Please fill in Phone");
$validator->addValidation("email","req","Please fill in Email and a valid email address");
$validator->addValidation("img_code","code","Security code is not matching ! Try again.");
$custom_validator = new MyValidator();
$validator->AddCustomValidator($custom_validator);
if($validator->ValidateForm())
{
// Send email to client
$message = '
Name '.$_POST['name'].'
Profession '.$_POST['profession'].'
Organization '.$_POST['organization'].'
Street Address '.$_POST['address'].'
City '.$_POST['city'].'
State '.$_POST['state'].'
Country '.$_POST['country'].'
Zip Code '.$_POST['zip'].'
Tel '.$_POST['phone'].'
E-mail '.$_POST['email'].'
Fax '.$_POST['fax'].'
Query '.$_POST['query'].'
';
//print $message;die;
// $to = 'info@sunrisetexbearings.com ' ;
$to = '' ;
$subject = 'Inquiry from sunrisetexbearings.com ';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";
$headers .= 'From: inquiry@sunrisetexbearings.com' . "\r\n";
$headers .= 'Reply-To: '.$_POST['email'].'' . "\r\n" ;
mail($to, $subject, $message, $headers);
// Remove all data from session
unset($_SESSION['name']);
unset($_SESSION['profession']);
unset($_SESSION['organization']);
unset($_SESSION['address']);
unset($_SESSION['city']);
unset($_SESSION['state']);
unset($_SESSION['country']);
unset($_SESSION['zip']);
unset($_SESSION['phone']);
unset($_SESSION['email']);
unset($_SESSION['fax']);
unset($_SESSION['query']);
$show_form= false;
// redirect page
?>
Thank you
Your detail has been submitted successfully. We will get back to your shortly
You can feel free to contact us
|
}
else
{
$error_hash = $validator->GetErrors();
$error.="";
foreach($error_hash as $inpname => $inp_err)
{
if($inpname=="name")
{
$nameerror = $inp_err;
}
if($inpname=="address")
{
$addresserror = $inp_err;
}
if($inpname=="phone")
{
$phoneerror = $inp_err;
}
if($inpname=="email")
{
$emailerror = $inp_err;
}
if($inpname=="query")
{
$queryerror = $inp_err;
}
if($inpname=="img_code")
{
$codeerror = $inp_err;
}
}
?>
See error below
}
/*/
}
else
{
?>
See error below
$codeerror = "Security code is not matching ! Try Again";
}
/*/
}
else
{
}
if(true == $show_form)
{
?>
| |
Please
take a few minutes to fill out details about yourself,
and the
information/services that you are interested in.
We will get in touch
with you once we receive your inquiry. |
|
|
| |
}
?> |
|
|
|
|