2016-11-02 47 views
0

我試圖使聯繫我們窗體工作,將聯繫表單鏈接到電子郵件HTML/PHP

P.S.我不是開發者,我的編碼技能非常有限。

這是HTML代碼:(從模板進行一些調整)

<!--Contact Starts --> 
 
<div class="container contactform center"> 
 
<h2 class="text-center wowload fadeInUp">Get in touch</h2> 
 
    <div class="row wowload fadeInLeftBig"> 
 
     <div class="col-sm-6 col-sm-offset-3 col-xs-12"> 
 
     <input type="text" placeholder="Name"> 
 
     <input type="text" placeholder="Company"> 
 
     <input type="text" placeholder="Email"> 
 
     <input type="text" placeholder="Subject"> 
 
     <textarea rows="5" placeholder="Message"></textarea> 
 
     <button class="btn btn-primary"><i class="fa fa-paper-plane"></i> Send</button> 
 

 
     </div> 
 
    </div>

,這是PHP腳本:(自己寫的)

$name = $_POST['Name'] ; 
 
$from = $_POST['Email'] ; 
 
$message = $_POST['Message'] ; 
 
$to = "[email protected]" ; 
 
$subject = "Website Contact Form" ; 
 

 
mail ($to, $subject, $message, "From: " . $name . $company . $email) ; 
 
echo "Your Message Has Been Sent" ;

我不確定我做錯了什麼,但它不是工作。

稱爲emailscript.php位於/assets/php/emailscript.php

現在我得到一個錯誤,這個錯誤的PHP文件:請求的文件沒有上找到「未找到

這臺服務器。「

+0

哪裏是你

標籤與action屬性? –

+0

哪裏是表單標籤。每個表單元素都應該有名稱屬性 –

+0

對不起,我忘了複製/過去:它是正確的在我發佈 – Balagosh

回答

1

嘗試這個...

<!--Contact Starts --> 
 
<div class="container contactform center"> 
 
<h2 class="text-center wowload fadeInUp">Get in touch</h2> 
 
    <div class="row wowload fadeInLeftBig"> 
 
     <div class="col-sm-6 col-sm-offset-3 col-xs-12"> 
 
     <form action="/assets/php/emailscript.php" method="post"> 
 
      <input type="text" placeholder="Name" name="Name"> 
 
      <input type="text" placeholder="Company" name="Company"> 
 
      <input type="text" placeholder="Email" name="Email"> 
 
      <input type="text" placeholder="Subject" name="Subject"> 
 
      <textarea rows="5" placeholder="Message" name="Message"></textarea> 
 
      <button type="submit" class="btn btn-primary"><i class="fa fa-paper-plane"></i> Send</button> 
 
     </form> 
 

 
     </div> 
 
    </div>

+0

[更新]即時消息得到回聲消息,但我沒有得到測試電子郵件到我的收件箱 – Balagosh

+0

[更新2]實際上它的工作!電子郵件去了垃圾郵件文件夾我不知道爲什麼,但它現在工作...謝謝你的人..真的很感謝你的努力:) – Balagosh

+0

好吧好吧來吧:)請問如果這個有用的問題 –

0

請將您的表單元素放在<form>標記中。並給每個元素一個name屬性。通過使用name屬性,我們將在php中獲得表單數據。

<form name="contact" action="/assets/php/emailscript.php" method="POST"> 
<input type="text" placeholder="Name" name="contact_name"> 
<input type="text" placeholder="Company" name="company"> 
<input type="text" placeholder="Email" name="email"> 
<input type="text" placeholder="Subject" name="subject"> 
<textarea rows="5" placeholder="Message" name="message"></textarea> 
<button class="btn btn-primary"><i class="fa fa-paper-plane"></i> Send</button> 
</form> 
+0

謝謝你的快速響應,我試過..仍然是同樣的錯誤 – Balagosh

+0

你的錯誤是什麼? –

+0

請檢查文件路徑 –

-2

圍繞您在isset函數代碼,以避免任何錯誤

<?php 
if(isset($_POST['Name'])) 
{ 

    $name=$_POST['Name'] ; 
    $from=$_POST['Email'] ; 
    $message=$_POST['Message'] ; 
    $to="[email protected]" ; 
    $subject="Website Contact Form" ; 

    mail ($to, $subject, $message, "From: " . $name . $company . $email) ; 
    // it echo not eco 
    echo "Your Message Has Been Sent" ; 

} 
?>