$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['address'] =$_POST['address'];
$_SESSION['phone'] =$_POST['phone'];
$_SESSION['email'] =$_POST['email'];
$_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'].'
Address= '.$_POST['address'].'
Tel= '.$_POST['phone'].'
E-mail= '.$_POST['email'].'
Query= '.$_POST['query'].'
';
//print $message;die;
$to = 'info@asutoshindia.com '.', ';
$to = 'marketing@asutoshindia.com';
$subject = 'Inquiry from asutoshindia.com ';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";
$headers .= 'From: inquiry@asutoshindia.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['address']);
unset($_SESSION['phone']);
unset($_SESSION['email']);
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. |
|
|
|
}
?>