请您查看我的代码并回答问题:为什么我收到空的电子邮件?我尝试过做很多事情,但似乎没有任何帮助:)
<?php
mb_internal_encoding('UTF-8');
mb_http_output('UTF-8');
mb_http_input('UTF-8');
mb_language('uni');
mb_regex_encoding('UTF-8');
ob_start('mb_output_handler');
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'radik.mcphilimy@gmail.com';
$subject = 'Сообщение от посетителя сайта '.$field_name;
$body_message = 'От: '.$field_name."\n";
$body_message .= 'Электронный ящик: '.$field_email."\n";
$body_message .= 'Сообщение: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('the message was sent.');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('the message was not sent.');
window.location = 'contact.html';
</script>
<?php
}
?>
这是html:
<form action="contact.php" method="post">
<div class="templatemo_form">
<input name="cf_name" type="text" class="form-control" id="cf_name" placeholder="your name" maxlength="40">
</div>
<div class="templatemo_form">
<input name="field_email" type="text" class="form-control" id="field_email" placeholder="your e-mail" maxlength="40">
</div>
<div class="templatemo_form">
<textarea name="field_message" rows="10" class="form-control" id="field_message" placeholder="Message"></textarea>
</div>
<div class="templatemo_form"><button type="submit" value="Send" class="btn btn-primary">Send</button></div>
非常感谢。 Radik
答案 0 :(得分:0)
您的HTML说:
name="field_message"
你的PHP说:
$_POST['cf_message'];
如果你从另一个名字读取然后发送,它就不起作用。