Muchas Gracias!
demoche
Código PHP:
<?php
require ("ClassMathGuard.php");
if($_POST)
{
$javascript_enabled = trim($_POST['browser_check']);
$department = trim($_POST['dept']);
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$phno = trim($_POST['phno']);
$subject = trim($_POST['subject']);
$msg = trim($_POST['msg']);
$selfcopy = trim($_POST['selfcopy']);
//mail settings
$sales_address = "[email protected]";
$support_address = "[email protected]";
$billing_address = "[email protected]";
$headers = "From: ".$email;
$message = "Contact name: $name\nContact Email: $email\nContact Phone: $phno\n\nMessage: $msg";
if (MathGuard :: checkResult($_POST['mathguard_answer'], $_POST['mathguard_code'])) {
if ( $department == "sales") $to = $sales_address;
elseif ( $department == "support") $to = $support_address;
elseif ( $department == "billing") $to = $billing_address;
if ( $name == "" )
{
$result = "Name field is required";
}
elseif (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/", $email))
{
$result = "Enter a valid email address";
}
elseif(!preg_match("/^[0-9]{2}-[0-9]{10}$/", $phno)) //check for a pattern of 91-0123456789
{
$result = "Enter a valid phone number";
}
elseif ( $subject == "" )
{
$result = "Subject is required";
}
elseif ( strlen($msg) < 10 )
{
$result = "Write more than 10 characters";
}
else
{
mail($to, $subject, $message, $headers);
if( $selfcopy == "yes" )
mail($email, $subject, $message, $headers);
$result = "Your mail has been sent succesfully!";
}
}
else $result = "Bad Answer, Please try again!";
if($javascript_enabled == "true") {
echo $result;
die();
}
}
?>