我已將聯繫表單添加到我的網站。表格發出電子郵件,但我沒有收到信息。所有的領域都是空白的。另外,我想讓所需的字段。任何人?HTML5,CSS3,PHP聯繫表格不發送信息+添加必填字段
這裏的PHP
<?php
$field_name = $_POST['Name...'];
$field_email = $_POST['Email...'];
$field_phone = $_POST['Phone...'];
$field_company = $_POST['Company'];
$field_message = $_POST['Message...'];
$mail_to = '[email protected]';
$subject = '#Message from Website# '.$field_name;
$body_message .= 'From: '.$field_name."\n";
$body_message .= 'Email: '.$field_email."\n";
$body_message .= 'Phone: '.$field_phone."\n";
$body_message .= 'Company: '.$field_company."\n";
$body_message .= 'Message: '.$field_message."\n";
$headers = 'From: '.$E-Mail."\r\n";
$headers .= 'Reply-To: '.$E-Mail."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'index.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message sending failed. Please, send an email to
[email protected]');
window.location = 'index.html';
</script>
<?php }
?>
這裏的表格
<form action="contact.php" method="post">
<input type="text" class="text" value="Name..." onfocus="this.value = '';" onblur="if (this.value =='') {this.value = 'Name...';}">
<input type="text" class="text" value="Email..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email...';}">
<input type="text" class="text" value="Phone..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Phone...';}">
<input type="text" class="text" value="Company..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Company...';}">
<textarea value="Message..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}">Message...</textarea>
<input class="wow shake" data-wow-delay="0.3s" type="submit" value="Send Message" />
</form>
這條線替換
有一個額外的'v': 'V $ field_phone = $ _ POST [ '電話......'];' – Knarf 2015-02-05 19:11:36
這是複製和粘貼錯誤...我的壞。 – 2015-02-05 19:30:27
現在,我如何使所需的字段? – 2015-02-05 19:40:22