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 树莓派启动AP热点传入数据
  • ¥15 multisim中关于74ls192n和DSWPK开关的问题(相关搜索:计数器)
  • ¥15 在误装Windows server2019 后如何利用Windows.old恢复?
  • ¥20 代码实现状态连接包过滤防火墙的设计与实现
  • ¥15 vscode的红色箭头爆红和has no default export报错
  • ¥15 关于#sql#的问题:#情况描述 在用vs对项目进行调试时,出现找不到网络路径,然后查看SQL配置工具,发现SQL服务显示远程调用过程失败(相关搜索:防火墙)
  • ¥15 eNSP中基于默认路由及浮动路由的公司与分部互联和校园网综合项目
  • ¥15 主要进行描述泥浆在管路不同区段泥浆的密度不相同,泥浆的密度有高有低,此时管路的摩阻分布需要怎么计算,(标签-matlab)
  • ¥40 通过编制程序计算圆管内层流充分发展对流换热,参数如图5-4,以及公式5-16所示,要求用表5-6对程序计算准确性进行验证