douweibiao8471 2014-06-18 20:09
浏览 18
已采纳

Textarea PHP帖子问题

I have a PHP post problem with a textarea. I've searched this site, and the suggested remedies involved pulling the textarea's ID, and making sure you are using htmlspecialchars. I'm doing both, and I still can't figure out why it won't post the contents of my textarea.

HTML

<form method="post" action="email.php" name="contactform" id="contactform" class="form form-stacked c-form">
<input name="name" type="text" id="name" placeholder="Name" />
<input name="email" type="text" id="email" placeholder="E-mail" />
<textarea name="theTextArea" placeholder="Message"></textarea>
<input type="submit" class="submit btn outline" id="submit" value="Send message" />
</form>

PHP

$realName = $name = $theMessage = $subject = $WHATmessage = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $realName = test_input($_POST["name"]);
  $name = test_input($_POST["email"]);
  $theMessage = test_input($_POST["theTextArea"]);
}
function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}

$subject = 'SUPERGROUP Inquiry - ' . $realName . ' - [' .date("F j, Y, g:i a").']';
$WHATmessage = $realName . ' is looking forward to hearing from us!'.PHP_EOL.'Their email is: '. $name .'!'.PHP_EOL.'They said: "'.$theMessage.'"';
mail('hello@sprgrp.com', $subject, $WHATmessage ); 
  • 写回答

2条回答 默认 最新

  • duanji9677 2014-06-18 20:36
    关注

    Posting comment as answer, as it appears to have worked.

    Have you tried all of this with single quotes rather than the double quotes you have there? PHP can be funny about that.

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

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器