2011-04-04 93 views
-1
<?php 
if(isset($_POST['email'])) { 

    // EDIT THE 2 LINES BELOW AS REQUIRED 
    $email_to = "[email protected]"; 
    $email_subject = "Request form sent from jadescientific.com.my"; 


    function died($error) { 
     // your error code can go here 
     echo "We are very sorry, but there were error(s) found with the form you submitted. "; 
     echo "These errors appear below.<br /><br />"; 
     echo $error."<br /><br />"; 
     echo "Please go back and fix these errors.<br /><br />"; 
     die(); 
    } 

    // validation expected data exists 
    if(!isset($_POST['name']) || 
     !isset($_POST['company_name']) || 
     !isset($_POST['email']) || 
     !isset($_POST['telephone']) || 
     !isset($_POST['product_interested'])) { 
     died('We are sorry, but there appears to be a problem with the form you submitted.');  
    } 

    $name = $_POST['name']; // required 
    $company_name = $_POST['company_name']; // required\ 
    $email= $_POST['email']; // not required 
    $telephone= $_POST['telephone']; // not required 
    $product_interested= $_POST['product_interested']; // required 

    $error_message = ""; 
    $email_exp = "^[A-Z0-9._%-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$"; 
    if(!eregi($email_exp,$email)) { 
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; 
    } 
    $string_exp = "^[a-z ./'-]+$"; 
    if(!eregi($string_exp,$name)) { 
    $error_message .= 'The Name you entered does not appear to be valid.<br />'; 
    } 
    if(!eregi($string_exp,$company_name)) { 
    $error_message .= 'The Company Name you entered does not appear to be valid.<br />'; 
    } 
    $varchar1_exp = "^[0-9 .'-]+$"; 
    if(!eregi($varchar1_exp,$telephone)) { 
    $error_message .= 'The telephone you entered does not appear to be valid.<br />'; 
    } 

    if(strlen($product_interested) < 2) { 
    $error_message .= 'The product interested you entered do not appear to be valid.<br />'; 
    } 
    if(strlen($error_message) > 0) { 
    died($error_message); 
    } 
    $email_message = "Form details below.\n\n"; 

    function clean_string($string) { 
     $bad = array("content-type","bcc:","to:","cc:","href"); 
     return str_replace($bad,"",$string); 
    } 

    $email_message .= "Name: ".clean_string($name)."\n"; 
    $email_message .= "Company Name: ".clean_string($company_name)."\n"; 
    $email_message .= "Email Address: ".clean_string($email)."\n"; 
    $email_message .= "Telephone: ".clean_string($telephone)."\n"; 
    $email_message .= "Product Interested: ".clean_string($product_interested)."\n"; 


// create email headers 
$headers = 'From: '.$email."\r\n". 
'Reply-To: '.$email."\r\n" . 
'X-Mailer: PHP/' . phpversion(); 
@mail($email_to, $email_subject, $email_message, $headers); 
?> 

<!-- include your own success html here --> 

Thank you for contacting us. We will be in touch with you very soon. 

<? 
} 
?> 
+3

究竟是什麼你問的是什麼?您可以指定回覆的發送位置,但用戶轉發和發送電子郵件的位置無法控制。 – Jonathan 2011-04-04 03:24:33

+1

或者,定義「轉發電子郵件地址」的含義。 – 2011-04-04 04:32:42

回答

0

這是怎麼了大部分工作,你

$first_name = $_POST['first_name']; // required 
$last_name = $_POST['last_name']; // required 
$email_from = $_POST['email']; // required 
$telephone = $_POST['telephone']; // not required 
$comments = $_POST['comments']; // required 


$email_exp = "^[A-Z0-9._%-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}$"; 
if(($email_from != "") && !eregi($email_exp,$email_from)) { 
$error_message .= 'The Email Address you entered does not appear to be valid.<br />'; 
相關問題