douh9817 2018-02-09 05:52
浏览 52
已采纳

带有下拉列表的PHP联系表单

I've been trying to figure this out for several days and cannot! I have searched and tried different codes, some javascript, some php, etc. I like the one I am using, I just need to figure out WHAT line of code to put in my PHP file.

Contact form has 4 fields. Upon submit, the form is emailed to me. While testing it, I receive the email with only 3 of the fields... The one I am not receiving is "users choice selected from dropdown box".

I found another thread almost identical to mine (on this site) and I tried what was suggested, but it did not work for me, and I don't know why. Here is the link to the thread by another user: PHP: Request the values of a HTML form drop down list

HTML

<select size="1" name="drop_down">
    <option value="Shows">Shows</option>
    <option value="Education">Education</option>
    <option value="Coaching">Coaching</option>
    <option value="Regional Convention Assistance">Regional Convention Assistance</option>
    <option value="Quartet Workshop: Vivapalooza!">Quartet Workshop: Vivapalooza!</option>
    <option value="Other">Other</option>
</select>

PHP

<?php 
if ($_POST["email"]<>'') { 
    $ToEmail = 'yecartdotcom@yahoo.com'; 
    $EmailSubject = 'Viva! Contact Form '; 
    $mailheader = "From: ".$_POST["email"]."
"; 
    $mailheader .= "Reply-To: ".$_POST["email"]."
"; 
    $mailheader .= "Content-type: text/html; charset=iso-8859-1
"; 
    $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
        $MESSAGE_BODY .= "Message: ".nl2br($_POST["message"])."<br>";
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
?> 
  • 写回答

1条回答 默认 最新

  • duanbeng6709 2018-02-09 05:56
    关注

    You simply miss to use drop down in your code.

    Update like below :-

    <?php 
    if ($_POST["email"]<>'') { 
        $ToEmail = 'myemail.com'; 
        $EmailSubject = 'Contact Form '; 
        $mailheader = "From: ".$_POST["email"]."
    "; 
        $mailheader .= "Reply-To: ".$_POST["email"]."
    "; 
        $mailheader .= "Content-type: text/html; charset=iso-8859-1
    "; 
        $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
        $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
        $MESSAGE_BODY .= "Message: ".nl2br($_POST["message"])."<br>";
        $MESSAGE_BODY .= "Drop Down: ".nl2br($_POST["drop_down"])."<br>";
        mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
    ?> 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?