2013-10-15 72 views
0

我不確定爲什麼我的聯繫人無法正常工作。它不會提交&發送數據到我的電子郵件地址。 檢查它在線 - http://www.arif-khan.net/project/chuck/ContactUs.html聯繫表單無法在提交

退房HTML代碼 -

<form id="contact-form" action="sendmail.php" method="POST" >      
        <div class="success">Contact form submitted!<br> 
         <strong>We will be in touch soon.</strong> 
        </div>      
        <fieldset> 
         <label class="name"> 
          <input name="name" type="text" value="Name:"> 
          <span class="error">*This is not a valid name.</span> 
          <span class="empty">*This field is required.</span> 
         </label> 
         <label class="email"> 
          <input name="email" type="email" value="Email:"> 
          <span class="error">*This is not a valid email address.</span> 
          <span class="empty">*This field is required.</span> 
         </label> 
         <label class="phone"> 
          <input name="contact" type="tel" value="Phone:"> 
          <span class="error">*This is not a valid phone number.</span> 
          <span class="empty">*This field is required.</span> 
         </label> 
         <label class="message"> 
          <textarea name="message">Message:</textarea> 
          <span class="error">*The message is too short.</span> 
          <span class="empty">*This field is required.</span> 
         </label> 
         <div class="form_buttons"> 
          <input type="submit" class="btn-1" value="submit" style="border:0px;"> 
          <!--a href="#" id="submit" class="btn-1 submit" data-type="submit">submit</a--> 
          <a href="#" class="btn-1" data-type="reset">Clear</a> 
          <input id="contact-form" type="hidden" name="contact-form" type="submit"/> 
         </div> 
        </fieldset> 
       </form>   

退房PHP代碼 -

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$message = $_POST['message']; 
$contact = $_POST['contact']; 
$to = "[email protected]"; 

$content = 'Customer Request From Pennant Staffing'; 

$body_message = '---------- Customer Details ---------- '."\r\n\r\n"; 
$body_message .= 'Name: '. $name."\r\n\r\n"; 
$body_message .= 'E-mail: ' . $email ."\r\n\r\n"; 
$body_message .= 'Contact: ' . $contact."\r\n\r\n"; 
$body_message .= 'Message: ' . $message."\r\n\r\n"; 

$headers = "From:$name<$email> \r\n"; 
$headers .= "Reply-To: $email \r\n"; 
mail($to, $content, $body_message, $headers); 
?> 

<script language="javascript" type="text/javascript"> 
window.location = 'ContactUs.html'; 
</script> 
+0

您是否也需要發佈您的HTML代碼? – Chandresh

+0

什麼不起作用?郵件沒有發送或其他東西? –

+0

郵件不發送 – arifix

回答

0

試試這個:

$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=UTF-8\r\n"; 
$headers .= "From:$name<$email> \r\n"; 
$headers .= "Reply-To: $email \r\n"; 
mail($to, $content, $body_message, $headers); 

檢查本地主機上的郵件你可以使用「測試郵件服務器工具」

0

你需要進入你使用此項目的php.ini文件,然後搜索

[mail function] 

並設置SMTP服務器的變量。