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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵