dragon071111 2014-10-04 16:52
浏览 30
已采纳

HTML表单不是“发布”PHP POST阵列的用户输入值。 我正在尝试通过电子邮件发送表格

Seemingly simple issue: I have an HTML form:

<form action="submit.php" method="post" enctype="text/plain">

            <h3>Owner Information</h3>
            First Name*: <br />
            <input type="text" name="firstname" /><br />
            Last Name*: <br />
            <input type="text" name="lastname" /><br /><br />
            Are you the owner on title?*: <br />
            <input type="radio" name="titleowner" value="yes" />Yes
            <input type="radio" name="titleowner" value="no" />No<br /><br />
</form>

And then here is submit.php:

<?php

$admin_email = "aloha@hi.com";
 $email = "hey@gmail.com";
$subject = "subject";
$message = htmlspecialchars($_POST['firstname'] . " " . $_POST['lastname']);
$message .= "Title Owner? " . htmlspecialchars($_POST["titleowner"]);
$message .= "Mailing Address: " . htmlspecialchars($_POST['mailingaddress']) . "City: " .      htmlspecialchars($_POST['city']) . "State:" . htmlspecialchars($_POST['state']) . "Zip Code" .   (int)$_POST['zipcode'] . "Phone Number:" . strip_tags($_POST['phoneNum']);

//send email
mail($admin_email, $subject, $message);

echo $message;

//Email response
echo "Thank you for contacting us!";
?>

The 'echo message' produces this when the user submits:

Title Owner? Mailing Address: City: State:Zip Code0Phone Number:Thank you for contacting us!

As you can see, the variable for some reason did not populate. Any help is very much appreciated. Thank you.

  • 写回答

2条回答 默认 最新

  • dourang8305 2014-10-04 16:53
    关注

    This:

    enctype="text/plain"
    

    is the culprit. The text/plain encoding isn't reliably machine decodable and PHP won't parse it.

    Remove the enctype attribute entirely.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看