【发布时间】:2015-04-05 18:51:28
【问题描述】:
我在我的网站上添加了一个联系表。表格发送电子邮件,但我没有收到信息。所有字段都是空白的。另外,我想填写必填字段。任何人?
这里是 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@me.com';
$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@me.com');
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['Phone...']; -
这是一个复制和粘贴错误……我的错。
-
现在,我怎样才能使这些字段成为必填项?
标签: javascript php html css forms