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 );