它是一个预订表格包含6个字段,名称,电话,签到日期,结帐日期,成人,房间...输入详细信息后我们提交,提交详细信息后,它来到我的电子邮件ID我指定的联系人.php ,,但我没有得到详细信息,我点击提交按钮,但它没有显示任何错误消息...你可以检查它,并给我正确的代码..或给我新的HTML与PHP代码为符合我要求的酒店预订表
<?php
$mailto = 'websitemail@gmail.com' ;
$subject = "Your Contact Form" ;
$thankyouurl = "http://www.wesite.com/thankyou.html" ;
$formurl = "http://www.website.com/index.html" ;
$errorurl = "http://www.website.com/error.html" ;
$uself = 0;
$use_sendmailfrom = 0;
$use_webmaster_email_for_from = 0;
$use_utf8 = 1;
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
if (isset( $use_sendmailfrom ) && $use_sendmailfrom) {
ini_set( 'sendmail_from', $mailto );
}
$firstname = addslashes($_POST['firstname']) ;
$phone = addslashes($_POST['phone']) ;
$checkin = addslashes($_POST['checkin']) ;
$checkout = addslashes($_POST['checkout']) ;
$adults = addslashes($_POST['adults']) ;
$rooms = addslashes($_POST['rooms']) ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($_POST['email'])) {
header( "Location: $formurl" );
exit ;
}
$valid_firstname = (!empty($firstname)) ? true : false;
$valid_phone = (!empty($phone)) ? true : false;
$valid_checkin = (!empty($checkin)) ? true : false;
$valid_checkout = (!empty($checkout)) ? true : false;
$valid_adults = (!empty($adults)) ? true : false;
$valid_rooms = (!empty($rooms)) ? true : false;
$fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ;
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------------------------------------------\n" .
"First Name: $firstname\n" .
"Phone: $Phone\n" .
"Check In: $checkin\n" .
"Check Out: $checkout\n" .
"Adults: $adults\n" .
"Number of Rooms: $rooms\n" .
"------------------------------------------------------------\n" ;
$headers = "From: \"$firstname\" <$fromemail>" . $headersep . "Reply-To: \"$firstname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.15.0" . $headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;
if ($valid_firstname && $valid_phone && $valid_checkin && $valid_checkout && $valid_adults && $valid_rooms) {
mail( $mailto, $subject, $messageproper, $headers );
}
else {
header( "Location: $errorurl" );
exit ;
}
header( "Location: $thankyouurl" );
exit ;
?>
HTML CODE::
<div class="contactform">enter code here
<span style="font-size: 9pt; font-family: Verdana; color: #000000;">
<form name="contactform" method="post" action="contact.php" onsubmit="return validateForm()">
<fieldset><legend><span style="font-size: 12px;"> CONTACT DETAILS </span></legend>
<label for="firstname" class="left">First name:</label>
<font color="#FF0000">*</font><input type="text" name="firstname" id="firstname" class="field" value="" maxlength="35" tabindex="1" /><br /><br />
<label for="phone" class="left">Phone:</label>
<font color="#FF0000">*</font><input type="text" name="phone" id="phone" class="field" value="" maxlength="10" tabindex="2" /><br /><br />
<label for="checkin" class="left">Check In:</label>
<font color="#FF0000">*</font><input type="text" class="datepicker" tabindex="3" /><br /><br />
<label for="checkout" class="left">Check Out:</label>
<font color="#FF0000">*</font><input type="text" class="datepicker" tabindex="4" /><br /><br />
<label for="adults" class="left">Persons:</label>
<font color="#FF0000">*</font><input type="text" name="adults" id="adults" class="field" value="" maxlength="45" tabindex="5" /><br /><br />
<label for="rooms" class="left">Number of Rooms:</label>
<font color="#FF0000">*</font><input type="text" name="city" id="city" class="field" value="" maxlength="35" tabindex="6" /><br /><br />
</fieldset>
<input type="reset" name="clear" id="clear" class="button" value="Clear" tabindex="7" />
<input type="submit" name="submit" id="submit" class="button" value="Send" tabindex="8" /><br /><br />
</fieldset>
</form>
</span>
</div>
答案 0 :(得分:1)
将此代码放在PHP文件的顶部以显示错误:
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
如果仍未显示错误,请访问php.ini
文件并设置Display_Errors = On