2013-02-05 91 views
1

我是新手,有人可以看看我的sendresults腳本,並告訴我我哪裏出錯了嗎?用PHP文件提交查詢表格

表單是一個單獨的HTML文檔,.php上傳到根目錄,我也有一個確認和error.html。提交時的表格空白。 這裏是腳本(我已經採取了完整的商業網站網址)

<?php 

// Subject 
$subject = "Results from Enquiry form"; 
// form information will be sent to. 
$mailto = 'my email'; 
//form url 
$formurl = "http://www...."; 
// redirect after form is processed. 
$confirmurl = 'http://www.....'; 
//redirect for errors 
$errorurl = "http://www...."; 

$email_is_required =1; 
$name_is_required =1; 
$comments_is_required = 1; 
$telephone_is_required = 1; 
$uself = 0; 
$forcelf = 0; 
$use_envsender = 0; 
$use_sendmailfrom = 0; 
$smtp_server_win = ""; 
$use_webmaster_email_for_from = 0; 
$use_utf8 = 1; 

define ('MAX_LINE_LENGTH', 900); 
$headersep = $uself ? "\n":"\r\n"; 
$content_nl = $forcelf ? "\n" : (defined('PHP_EOL') ? PHP_EOL : "\n"); 
$content_type = $use_utf8 ? 'Content-Type: text/plain; charset="utf-8"' : 'Content-Type: text/plain; charset="iso-8859-1"'; 
if ($use_sendmailfrom) { 
    ini_set('sendmail_from', $mailto); 
} 

$envsender = "-f$mailto"; 
$name = isset($_POST['name']) ? 
    $_POST['name']: $_POST['name']; 
    $address = $_POST['address']; 
    $city = $_POST['city']; 
    $state = $_POST['state']; 
    $postcode = $_POST['postcode']; 
    $telephone = $_POST['telephone']; 
    $email = $_POST['email']; 
    $comments = $_POST['comments']; 
    $bushwalking = $_POST['bushwalking']; 
    $trout_fishing = $_POST['trout_fishing']; 
    $canoeing = $_POST['canoeing']; 
    $accommodation = $_POST['accommodation']; 
    $corporate_events = $_POST['corporate_events']; 
    $guests_for_accomm = $_POST['guests_for_accomm']; 
    $stay = $_POST['stay']; 
    $dday = $_POST['dday']; 
    $dMonth = $_POST['dMonth']; 
    $dYear = $_POST['dYear']; 
    $http_referrer = getenv ("HTTP_REFERER"); 

if (!isset($_POST['email'])) { 
    header("Location: $formurl"); 
    exit; 
} 
if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($name)) || ($comments_is_required && empty($comments))) { 
      header("Location: $errorurl"); 
      exit; 
} 
if (preg_match("/[\r\n]/", $name) || preg_match ("/[\r\n]/", $email)) {header("Location: $errorurl"); 
exit; 
} 
if (empty($email)) { 
    $email = $mailto ; 
} 
$fromemail = $use_webmaster_email_for_from ? $mailto : $email; 
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { 
    $comments = stripslashes ($comments); 
} 
$messageproper = "Ths message was sent from:" . $content_nl . 
       "http_referer" . $content_nl . 
       "----------------------------------------------------------------- 
       " . $content_nl . 
       "Name of sender: $name" . $content_nl . 
       "Address of sender: $address" . $content_nl . 
       "City of sender: $city" . $content_nl . 
       "State of sender: $state" . $content_nl . 
       "Postcode of sender: $postcode" . $content_nl . 
       "Telephone of sender: $telephone" . $content_nl . 
       "Email of sender: $email" . $content_nl . 
       "Required information: $bushwalking, $trout_fishing, $canoeing, $accommodation, $corporate_events " . $content_nl . 
       "Number of guest: $guests_for_accomm" . $content_nl . 
       "Length of stay: $stay" . $content_nl . 
       "Date if arrival: $dday, dMonth, dYear" . $content_nl . 
       "-------------------------------------------COMMENTS--------------------------------------" . $content_nl . $contents_nl . 
       wordwrap($comments, MAX_LINE_LENGTH, $content_nl, true) . $content_nl . $content_nl . "---------------------------------------------------------------------------------------------------------" . $content_nl ; 
       $headers = "From:\"$name\" <$fromemail>" . 
       $headersep . "Reply-To:\"$name\"<$email>" . 
       $headersep . "X-Mailer: chfeedback.php 2.16.2" . 
       $headersep . 'MIME-Version: 1.0' . $headersep . $content_type ; 
if ($use_envsender) { 
     if(mail($mailto, $subject, $messageproper, $headers, $envsender)) 
     { 
      echo("Location: $confirmurl"); 
}} 
else { 
      echo("Location: $errorurl"); 
} 
?> 

Here is the html 
<body> 
<div id="apDiv1"> 
<div class="form"><form id="enquiry_form" name="enquiry_form" method="post" action="/sendresults.php" enctype="text/plain" onsubmit="return exec()"> 
    <table width= "420" border="0" cellpadding="0" cellspacing="5"> 
    <tr><td height="15" colspan="2"></td> 
    <tr> 
     <th colspan="2">Please enter details for your enquiry below<br/><br/> 
     </th> 
    </tr> 
    <tr> 
     <td width="25%" align="left"> 
     Name:</td> 
      <td width="75%"><label><input name="name" type="text" class="content_fieldset" id="name" value=""/>* 
      </label></td> 
     </tr> 
     <tr> 
     <td>Address:</td> 
      <td><label><input name="address" id="address" type="text" class="content_fieldset" value="" /></label></td> 
      </tr> 
     <tr><td>City:</td> 
      <td><label><input name="city" id="city" type="text" class="content_fieldset" value="" /></label></td> 
      </tr> 
     <tr><td>State:</td> 
      <td><label><input name="state" id="state" type="text" class="content_fieldset" value="" /></label></td> 
      </tr> 
     <tr><td>Postcode:</td> 
     <td><label><input name="postcode" id="postcode" type="text" class="content_fieldset" value="" /></label></td></tr> 
      </tr> 
     <tr><td>Telephone:</td> 
      <td><label><input name="telephone" type="text" class="content_fieldset" id="telephone" value="" />*</label></td> 
      </tr> 
    <tr><td>E-mail:</td> 
      <td><label><input name="email" type="text" class="content_fieldset" id="email" value=""/>*</label></td> 
      </tr> 
     <tr> 
      <td colspan="2" align="right">* Required fields</td> 
     </tr> 
     <tr><td height="15" colspan="2"></td></tr> 
      <tr><td colspan="2"> What would you like information about?</td> 
      </tr> 
     <tr><td height="10" colspan="2"></td></tr> 
      <tr><td width=10%><label><input type="checkbox" name="bushwalking" id="bushwalking" value="bushwalking" checked="checked" /></label></td><td>Bush walking</td>   </tr> 
      <tr><td><label><input type="checkbox" name="trout_fishing" id="trout_fishing" value="trout_fishing" /></label></td><td>Trout Fishing</td> 
      </tr> 
      <tr><td><label><input type="checkbox" name="canoeing" id="canoeing" value="canoeing" /></label></td><td>Canoeing</td> 
      </tr> 
      <tr><td><label><input type="checkbox" name="corporate_events" id="corporate_events" value="corporate_events" /></label></td><td>Corporate Events</td> 
      </tr> 
      <tr><td><label><input type="checkbox" name="accommodation" id="accommodation" value="accommodation" checked="checked" /></label></td><td>Accommodation</td> 
      </tr> 
      <tr><td height="20" colspan="2"></td> 
      </tr> 
      <tr><td width="40%">No. of Guests requiring accommodation:</td> 
      <td><label><input name="guests_for_accomm" type="text" id="guests_for_accomm" size="3" value="" /></label></td> 
      <tr><td height="15" colspan="2"></td> 
      </tr> 
      <tr><td>Length of Stay:</td><td><label> 
      <select name="stay" id="stay"> 
      <option>0 nights</option> 
      <option>1 night</option> 
      <option>2 nights</option> 
      <option>3 nights</option> 
      <option>4 nights</option> 
      <option>5 nights</option> 
      <option>6 nights</option> 
      <option>7 nights</option> 
      <option>8 nights</option> 
      <option>9 nights</option> 
      <option>10 nights</option> 
      </select> 
      </label></td> 
      </tr> 
      <tr><td height="15" colspan="2"></td> 
      <tr><td width="35%">Date of Arrival:</td> 
      <td><select name="dday" id="dday"> 
      <option value="01" >1</option> 
      <option value="02" >2</option> 
      <option value="03" >3</option> 
      <option value="04" >4</option> 
      <option value="05" >5</option> 
      <option value="06" >6</option> 
      <option value="07" >7</option> 
      <option value="08" >8</option> 
      <option value="09" >9</option> 
      <option value="10" >10</option> 
      <option value="11" >11</option> 
      <option value="12" >12</option> 
      <option value="13" >13</option> 
      <option value="14" >14</option> 
      <option value="15" >15</option> 
      <option value="16" >16</option> 
      <option value="17" >17</option> 
      <option value="18" >18</option> 
      <option value="19" >19</option> 
      <option value="20" >20</option> 
      <option value="21" >21</option> 
      <option value="22" >22</option> 
      <option value="23" >23</option> 
      <option value="24" >24</option> 
      <option value="25" >25</option> 
      <option value="26" >26</option> 
      <option value="27" >27</option> 
      <option value="28" >28</option> 
      <option value="29" >29</option> 
      <option value="30" >30</option> 
      <option value="31" >31</option> 
      </select> 
      <select name="dMonth" id="dMonth"> 
      <option value="01" >January</option> 
      <option value="02" >February</option> 
      <option value="03" >March</option> 
      <option value="04" >April</option> 
      <option value="05" >May</option> 
      <option value="06" >June</option> 
      <option value="07" >July</option> 
      <option value="08" >August</option> 
      <option value="09" >September</option> 
      <option value="10" >October</option> 
      <option value="11" >November</option> 
      <option value="12" >December</option> 
      </select> 
      <select name="dYear" id="dYear"> 
      <option value="2012" >2013</option> 
      <option value="2013" >2014</option> 
      <option value="2014" >2015</option> 
      <option value="2015" >2016</option> 
      <option value="2016" >2017</option> 
      <option value="2017" >2018</option> 
      </select></td> 
      </tr> 
     <tr><td height="15" colspan="2"></td> 
      <tr><td>Comments:</td> 
      <td><textarea name="comments" rows="6" cols="30" id="comments" ></textarea></td> 
     </tr> 
     <tr><td height="15" colspan="2"></td> 
      <tr><td colspan="2"><label><input name="submit" type="submit" class="button" id="submit" value="Submit"/> 
      <input type="reset" value="Reset"/></label></td> 
     </tr> 
    </table> 
</form></div></div> 
+1

空白頁通常表示致命錯誤。檢查你的錯誤日誌。 – MrCode

+0

你是什麼意思的空白頁? – user2042111

回答

1
<?php 
// Subject 
$subject = "Results from Enquiry form"; 
// form information will be sent to. 
$mailto = '[email protected]'; 
//form url 
$formurl = "http://www.e247dubai.com"; 
// redirect after form is processed. 
$confirmurl = 'http://www.e247dubai.com'; 
//redirect for errors 
$errorurl = "http://www.e247dubai.com"; 

$email_is_required =1; 
$name_is_required =1; 
$comments_is_required = 1; 
$telephone_is_required = 1; 
$uself = 0; 
$forcelf = 0; 
$use_envsender = 1; 
$use_sendmailfrom = 0; 
$smtp_server_win = ""; 
$use_webmaster_email_for_from = 0; 
$use_utf8 = 1; 
define ('MAX_LINE_LENGTH', 900); 
$headersep = $uself ? "\n":"\r\n"; 
$content_nl = $forcelf ? "\n" : (defined('PHP_EOL') ? PHP_EOL : "\n"); 
$content_type = $use_utf8 ? 'Content-Type: text/plain; charset="utf-8"' : 'Content-Type: text/plain; charset="iso-8859-1"'; 
if ($use_sendmailfrom) { 
    ini_set('sendmail_from', $mailto); 
} 

$envsender= "-f$mailto"; 
$name = isset($_POST['name']) ? $_POST['name']: $_POST['name']; 
$address=$_POST['address']; 
$city=$_POST['city']; 
$state=$_POST['state']; 
$postcode=$_POST['postcode']; 
$telephone=$_POST['telephone']; 
$email=$_POST['email']; 
$comments=$_POST['comments']; 
$bushwalking=$_POST['bushwalking']; 
$trout_fishing=$_POST['trout_fishing']; 
$canoeing=$_POST['canoeing']; 
$accommodation=$_POST['accommodation']; 
$corporate_events=$_POST['corporate_events']; 
$guests_for_accomm=$_POST['guests_for_accomm']; 
$stay=$_POST['stay']; 
$dday=$_POST['dday']; 
$dMonth=$_POST['dMonth']; 
$dYear=$_POST['dYear']; 
$http_referrer=getenv ("HTTP_REFERER"); 
if (!isset($_POST['email'])) { 
header("Location: $formurl"); 
exit; 
} 
if (($email_is_required && (empty($email) || !preg_match('/@/', $email))) || ($name_is_required && empty($name)) || ($comments_is_required && empty($comments))) { 
header("Location: $errorurl"); 
exit; 
} 
if (preg_match("/[\r\n]/", $name) || preg_match ("/[\r\n]/", $email)) {header("Location: $errorurl"); 
exit; 
} 
if (empty($email)) { 
$email = $mailto ; 
} 
$fromemail = $use_webmaster_email_for_from ? $mailto : $email; 
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { 
$comments = stripslashes ($comments); 
} 
//echo "name :".$name. " Address: ".$address." City:".$city; 
$messageproper = "Ths message was sent from:" . $content_nl . 
"http_referer" . $content_nl . 
"----------------------------------------------------------------- 
" . $content_nl . 
"Name of sender: $name" . $content_nl . 
"Address of sender: $address" . $content_nl . 
"City of sender: $city" . $content_nl . 
"State of sender: $state" . $content_nl . 
"Postcode of sender: $postcode" . $content_nl . 
"Telephone of sender: $telephone" . $content_nl . 
"Email of sender: $email" . $content_nl . 
"Required information: $bushwalking, $trout_fishing, $canoeing, $accommodation, $corporate_events " . $content_nl . 
"Number of guest: $guests_for_accomm" . $content_nl . 
"Length of stay: $stay" . $content_nl . 
"Date if arrival: $dday, dMonth, dYear" . $content_nl . 
"-------------------------------------------COMMENTS--------------------------------------" . $content_nl . $contents_nl . 
wordwrap($comments, MAX_LINE_LENGTH, $content_nl, true) . $content_nl . $content_nl . "---------------------------------------------------------------------------------------------------------" . $content_nl ; 
$headers = "From:\"$name\" <$fromemail>" . 
$headersep . "Reply-To:\"$name\"<$email>" . 
$headersep . "X-Mailer: chfeedback.php 2.16.2" . 
$headersep . 'MIME-Version: 1.0' . $headersep . $content_type ; 
if ($use_envsender) { 
if(mail($mailto, $subject, $messageproper, $headers, $envsender)) 
{ 
echo ("Location: $confirmurl"); 
}} 
else { 
echo("Location: $errorurl"); 
} 
?> 

試試這個。

+0

我試過了,拿出所有的空白處,對不起,它沒有工作 – user2042111

+0

@ user2042111把$ use_envsender = 1;它的工作我試過了 – ukdub

+0

好的,我改變了t0 = 1,但仍然是空白字段的形式,我沒有得到任何confirmed.html或電子郵件,這可能是與$ headersep。 「X-Mailer:chfeedback.php 2.16.2」主機是網絡城市? – user2042111