2014-04-01 130 views
0

當客戶填寫我的申請時,會通過電子郵件發送給我的電子郵件地址。電子郵件包含表格中的所有信息,但聯繫人聽到的有關該網站的信息除外。在這個選項中是一個下拉菜單。任何建議將是偉大的。通過電子郵件發送聯繫表格信息

這是形式:

<div class="Row"> 
<div class="Lable">Full Name:</div> <!--End of Lable--> 
<div class="input"> 
<input type="text" id="fullname" class="detail" name="fullname" placeholder="Full Name" /> 
</div> <!--End input--> 
</div> <!--End row--> 


<br /> 
<div class="Row"> 
<div class="Lable">Email Address:</div> <!--End of Lable--> 
<div class="input"> 
<input type="text" id="emailaddress" class="detail" name="emailaddress" placeholder="Email Address" /> 
</div> <!--End input--> 
</div> <!--End row--> 

    <br /> 
<div class="Row"> 
<div class="Lable">Your Message:</div> <!--End of Lable--> 
<div class="input"> 
<textarea id="comment" name="comment" class="mess" placeholder="Your Message"></textarea> 
</div> <!--End input--> 
</div> <!--End row--> 

<br /> 
<div class="Row"> 
<div class="Lable">Select your gender:</div> <!--End of Lable--> 
<div class="input"> 
<input type="radio" name="gender" value="male" id="gender_male" CHECKED/> 
<label for="gender_male"/>Male 
<input type="radio" name="gender" value="female" id="gender_female" /> 
<label for="gender_female" />Female 
</div> <!--End input--> 
</div> <!--End row--> 




<br /> 
<div class="Row"> 
<div class="Lable">Please select your age:</div> 
    <!--End of Lable--> 
    <input type="radio" name="age" id="range1" value="18-25" CHECKED /> 
    18-25 
    <input type="radio" name="age" id="range2" value="26-33" />26-33 
    <input type="radio" name="age" id="range3" value="24-40" />34-40 
    <input type="radio" name="age" id="range4" value="40+" />40+<br /> 
</div><!--Row--> 

    <br /> 
    <div class="Row"> 
<div class="Lable">Select 3 products that you are interested in hearing about:</div> 
<!--End of Lable--> 
<input type="checkbox" name="Interested[]" id="protien" value="protien" />Protien 
<input type="checkbox" name="Interested[]" id="creatine" value="creatine" />Creatine<br> 
<input type="checkbox" name="Interested[]" id="bcaa" value="bcaa" />BCAA 
<input type="checkbox" name="Interested[]" id="power drinks" value="powerdrinks" />Power Drinks<br /> 
</div><!--Row--> 





<br /> 
<div class="Row"> 
<div class="Lable">Where did you hear about us?</div> <!--End of Lable--> 
<select> 
<option value="Google" selected="selected" name="Google" id="heard" /> Google Search 
<option value="WordOfMouth" name="heard" id="WordOfMouth" /> Word of mouth 
<option value="Newspaper" name="heard" id="Neawspaper" /> Newspaper 
<option value="Magazine" name="heard" id="Magazine" /> Magazine 
</select> 
</div><!--Row--> 



<br /> 
<div class="submit"> 
<input type="submit" id="send" Name="send" value="Send" /> 
</div><!--End of submit--> 

<div class="Clear"> 
<input type="reset" id="clear" Name="Clear" value="Clear" /> 
</div> 





</form> 

這是reply.php行動:

$name = $_POST["fullname"]; 
$email = $_POST["emailaddress"]; 
$comments = $_POST["comment"]; 
$gender = $_POST["gender"]; 
$age = $_POST["age"]; 
$Interested = $_POST['Interested']; 
$heard = $_POST["heard"]; 


$message = "New Email for a customer" . 



     "\r\nName of the contact" . 
     "\r\n-". $name . 
     "\r\nEmail address of the contact" . 
     "\r\n-".$email . 
     "\r\nThe comment that the contact has made" . 
     "\r\n-".$comments . 
     "\r\nThe gender of the contact" . 
     "\r\n-".$gender . 
     "\r\nThe age range of the contact" . 
     "\r\n-".$age . 
     "\r\nThe products that the customer is interested in" . 
     "\r\n-".implode(", " ,$Interested). 
     "\r\nWhere the contact heard of Shredded Nutrition" . 
     "\r\n-".$Heard . 
     "\r\n-" . 
    $headers = "From: " . $email; 


mail("[email protected]",$subject,$message,$headers); 
$subjectReply = 'Thank you for your contact..'; 
$messageReply = 'You will soon receive an answer'; 
$headers = 'From: [email protected]'; 

mail($email, $subjectReply, $messageReply, $headers); 
?> 
+0

可能很簡單,因爲您將選擇值分配給'$ heard',但在$ message變量中使用了$ Heard。 –

+0

謝謝這是我嘗試分類時的錯誤。 – Kie21

回答

3

你的選擇應該命名爲heard

即:

<select name="heard"> 

,並移除選項name="heard"value會照顧到這一點。


<select name="heard"> 
<option value="Google" selected="selected" id="heard" /> Google Search 
<option value="WordOfMouth" id="WordOfMouth" /> Word of mouth 
<option value="Newspaper" id="Neawspaper" /> Newspaper 
<option value="Magazine" id="Magazine" /> Magazine 
</select> 

而且,由於你使用$heard = $_POST["heard"];

更具體地改變.$Heard.$heard

"\r\n-".$Heard ."\r\n-".$heard .

POST變量是區分大小寫的。如果不這樣做,您將無法在電子郵件中看到選擇。

+1

這是最正確的答案,從

+0

刪除了'name =「Google」''謝謝!現在排序了。 – Kie21

+0

不客氣。 @ Kie21 –

0

你的選擇應該有名聞,而不是選項內。 select是實際發送迴應用程序的內容,這些選項更多是用戶可以選擇的值。添加下面的內容,但刪除您目前的頂部選項中聽到的ID。

<br /> 
<div class="Row"> 
<div class="Lable">Where did you hear about us?</div> <!--End of Lable--> 
<select name="heard"> 
<option value="Google" selected="selected" name="Google"> Google Search</option> 
<option value="WordOfMouth" id="WordOfMouth"> Word of mouth </option> 
<option value="Newspaper" id="Neawspaper"> Newspaper</option> 
<option value="Magazine" id="Magazine"> Magazine</option> 
</select> 
</div><!--Row--> 

應該解決它。

+2

不,它應該是'name'屬性而不是id –

+0

@Dagon你是對的。我的糟糕,一天結束,所有這一切。 – Gyhth

+0

當提交表單時,'value =「」'屬性被傳遞給服務器,而不是'id =「」''屬性。 –

相關問題