-3
您能否看看我的代码并回答问题:为什么我会收到空的电子邮件?我试着做了很多事情,但似乎没有任何帮助:)反馈表格发送空的电子邮件
<?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 = '[email protected]';
$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
[HTML5占位符属性不是标签元素的替代品](http://www.456bereastreet.com/archive/201204/the_html5_placeholder_attribute_is_not_a_substitute_for_the_label_element/) – Quentin 2014-10-29 10:26:50
告诉我们您尝试了什么,并向我们展示出现问题的代码...看看[问];) – mithrop 2014-10-29 10:26:59
您是否尝试过将表单中的'name'值与您在PHP中解析的内容进行匹配? – 2014-10-29 10:27:03