-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