我的网站上有一个表单,该表单与电子邮件中未发送的textarea数据不同。表单允许人们输入姓名,电子邮件和消息。我收到了电子邮件,但我收到了姓名和电子邮件,但“消息”区域是空白的。
我甚至尝试将textarea更改为输入字段,但即使这是在电子邮件中发送的?我不知道为什么这不起作用。任何人都可以帮忙。
下面是HTML表单代码以及PHP邮件。
HTML
<form enctype="multipart/form-data" method="post" action="php/mail.php" name="cform" id="cform">
<input name="name" id="name" type="text" class="col-xs-12 col-sm-6 col-md-6 col-lg-6" placeholder="Your name..." >
<input name="email" id="email" type="email" class="col-xs-12 col-sm-6 col-md-6 col-lg-6 noMarr" placeholder="Your email..." >
<textarea name="message" id="message" type="text" cols="40" rows="5" class="col-xs-12 col-sm-12 col-md-12 col-lg-12" placeholder="Your message..."></textarea>
<input type="submit" id="submit" name="send" class="submitBnt" value="Send Message">
</form>
PHP
<?
require("class.phpmailer.php");
// form validation vars
$formok = true;
$errors = array();
// sumbission data
$ipaddress = $_SERVER['REMOTE_ADDR'];
$date = date('d/m/Y');
$time = date('H:i:s');
// form data
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP - mail or smtp.domain.com
$mail->Host = "myserver"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "myUsername"; // SMTP username
$mail->Password = "myPassword"; // SMTP password
$mail->From = "myEmail@Address.com"; // SMTP username
$mail->AddAddress("myEmail@Address.com"); // Your Adress
$mail->Subject = "New contact request from My Website !";
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Body = "<p>You have recieved a new message from the enquiries form on your website.</p>
<p>
<strong>Name: </strong>{$name}
</p>
<p>
<strong>Email Address: </strong>{$email}
</p>
<p>
<strong>Message: </strong>{$message} // NOT WORKING HERE
</p>
<p>
This message was sent from the IP Address: {$ipaddress} on {$date} at {$time}
</p>";
if(!$mail->Send())
{
echo "There was an error... unable to send email <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Thank you. Your email has been sent.";
?>
答案 0 :(得分:1)
由于&#39;消息&#39;服务器上没有收到post参数,这是在前端清除的。这可能是由表单的javascript验证或用于编辑字段的任何WYSIWYG引起的。