2013-05-07 107 views
0

我創建了一個使用php郵件腳本提交的HTML表單。我遇到的問題是,表格每天提交一次完全空白,每天晚上一小時後完全空白。我完全陷入困境,我希望有人能幫助發現我的問題。表單每天提交一次空白(每次只有一個小時不同)

我粘貼下面的代碼,請注意:html表單的結束位置在使用Adobe CQ5的網站的頁面內,php腳本在單獨的服務器上,我已經刪除了所有驗證以檢查如果這是問題(這不是 - 它仍然提交空白有或沒有我的驗證代碼)。

HTML表單代碼:

<font size="2"><strong>* Required</strong></font><P><BR><form name="form1" action="http://mtindustrialservicerequest.com/phpFiles/send_form_email_ci-vision.php" method="post"> 
<p><strong>Lead Submitted by: </strong><br/> 
*Name: <input name="submit_name" type="text" id="submit_name" size="40"><br/> 
*Company Name: <input name="companyName" type="text" id="CompanyName" size="40"><br/> 
*City: <input name="companyCity" type="text" id="CompanyCity" size="25"> 
*State: <input name="companyState" type="text" id="CompanyState" size="15"></p> 
<BR> 
<p>Purchase Timeframe: <select name="timeframe" id="Timeframe"> 
<option value="0 - 6 months">0 - 6 months</option> 
<option value="7 - 12 months">7 - 12 months</option> 
</select> 
</p> 
<BR> 
<p> 
<strong>Customer Interest: </strong><br/> 
<input type="checkbox" name="Product" value="Yes">Product<br/> 
<input type="checkbox" name="Service" value="Yes">Service 
</p> 
<BR> 
<p><strong>Customer Information: </strong><br/> 
Application Details and Comments:<br/> 
<textarea name="CustomerApplication" cols="55" rows="5" id="Customer Application"></textarea><br/> 
<select name="Salutation" id="Salutation"> 
<option value="Mr">Mr.</option> 
<option value="Ms">Ms.</option> 
<option value="Mrs">Mrs.</option> 
</select> 
*First Name: <input name="CustomerFirstName" type="text" id="CustomerFirstName" size="25"> 
*Last Name: <input name="CustomerLastName" type="text" id="CustomerLastName" size="25"><BR> 
Email: <input name="CustomerEmail" type="text" id="CustomerEmail" size="40"><br/> 
*Phone Number: <input name="CustomerPhone" type="text" id="CustomerPhone" size="20"> 
Fax Number: <input name="CustomerFax" type="text" id="CustomerFax" size="20"><br/> 
Job Title: <input name="CustomerJobTitle" type="text" id="CustomerJobTitle" size="40"><br/> 
*Company Name: <input name="CustomerCompanyName" type="text" id="CustomerCompanyName" size="30"> 
Department: <input name="CustomerDepartment" type="text" id="CustomerDepartment" size="25"><br/> 
*Address: <input name="CustomerStreet" type="text" id="CustomerStreet" size="50"> <BR> 
*City: <input name="CustomerCity" type="text" id="CustomerCity" size="25"> 
*State: <input name="CustomerState" type="text" id="CustomerState" size="15"> 
*Postal Code: <input name="CustomerPostalCode" type="text" id="CustomerPostalCode" size="10"><br/> 
Country: <input name="CustomerCountry" type="text" id="CustomerCountry" size="12"><br/> 
</p> 

<p> 
Contact Workplace:<select name="BusinessType" id"BusinessType"> 
<option value="--------">--- Select One ---</option> 
<option value="Research and Development">Research and Development</option> 
<option value="Engineering, Process Development and Scale-Up">Engineering, Process Development and Scale-Up</option> 
<option value="General Laboratory, Inspection and Quality Control">General Laboratory, Inspection and Quality Control</option> 
<option value="Receiving and Warehousing">Receiving and Warehousing</option> 
<option value="Production and Processing">Production and Processing</option> 
<option value="Packaging and Filling">Packaging and Filling</option> 
<option value="Logistics, Shipping and Mail">Logistics, Shipping and Mail</option> 
<option value="Maintenance and Service">Maintenance and Service</option> 
<option value="Information Technology">Information Technology</option> 
<option value="Retail">Retail</option> 
<option value="Water, Power and facility Utilities">Water, Power and Facility Utilities</option> 
<option value="Procurement, Finance and Administration">Procurement, Finance and Administration</option> 
<option value="Dealers and Distributors">Dealers and Distributors</option> 
<option value="Other">Other</option> 
</select><br/> 
Industry:<select name="industryType" id"IndustryType"> 
<option value="--------">--- Select One ---</option> 
<option value="Chemical">Chemical</option> 
<option value="Pharma and Biotechnology">Pharma and Biotechnology</option> 
<option value="Food and Beverage">Food and Beverage</option> 
<option value="Academia and Education">Academia and Education</option> 
<option value="Testing Labs and Health Institutes">Testing Labs and Health Institutes</option> 
<option value="Metal, Plastics and Electronics Components">Metal, Plastics and Electronics Components</option> 
<option value="Raw Materials and Jewelry">Raw Materials and Jewelry</option> 
<option value="Pulp, Paper and Textile">Pulp, Paper and Textile</option> 
<option value="Engineering, Machinery and Equipment Manufacturing">Engineering, Machinery and Equipment Manufacturing</option> 
<option value="Transport and Logistics">Transport and Logistics</option> 
<option value="Utilities and Municipalities">Utilities and Municipalities</option> 
<option value="Retail">Retail</option> 
</select><br/> 
Number of Employees:<select name="Employees" id"Employees"> 
<option value="--------">--- Select One ---</option> 
<option value="Between 1 and 50">Between 1 and 50</option> 
<option value="Between 50 and 200">Between 50 and 200</option> 
<option value="Between 200 and 500">Between 200 and 500</option> 
<option value="Between 500 and 1000">Between 500 and 1000</option> 
<option value="1000 or more">1000 or more</option> 
</select> 
</p> 

<p><input type="submit" name="Submit" value=" Submit "></p> 
</form> 

PHP腳本:

<?php 

    // EDIT THE 2 LINES BELOW AS REQUIRED 
    $email_to = "[email protected]"; 
    $email_subject = "New CI-Vision Lead! PI/IND Lead Sharing Program"; 

    if(!isset($_POST['submit_name'])){$submit_name = " ";} 
    else{$submit_name = $_POST['submit_name'];} 

    if(!isset($_POST['companyName'])){$companyName = " ";} 
    else{$companyName = $_POST['companyName'];} 

    if(!isset($_POST['companyLocation'])){$companyLocation = " ";} 
    else{$companyLocation = $_POST['companyLocation'];} 

    if(!isset($_POST['companyCity'])){$companyCity = " ";} 
    else{$companyCity = $_POST['companyCity'];} 

    if(!isset($_POST['companyState'])){$companyState = " ";} 
    else{$companyState = $_POST['companyState'];} 

    if(!isset($_POST['timeframe'])){$timeframe = " ";} 
    else{$timeframe = $_POST['timeframe'];} 


    if(!isset($_POST['Product'])){$product = " ";} 
    else{$product = $_POST['Product'];} 

    if(!isset($_POST['Service'])){$service = " ";} 
    else{$service = $_POST['Service'];} 


    if(!isset($_POST['CustomerApplication'])){$customerApplication = " ";} 
    else{$customerApplication = $_POST['CustomerApplication'];} 

    if(!isset($_POST['Salutation'])){$salutation = " ";} 
    else{$salutation = $_POST['Salutation'];} 

    if(!isset($_POST['CustomerFirstName'])){$customerFirstName = " ";} 
    else{$customerFirstName = $_POST['CustomerFirstName'];} 

    if(!isset($_POST['CustomerLastName'])){$customerLastName = " ";} 
    else{$customerLastName = $_POST['CustomerLastName'];} 

    if(!isset($_POST['CustomerAcademicTitle'])){$customerAcademicTitle = " ";} 
    else{$customerAcademicTitle = $_POST['CustomerAcademicTitle'];} 

    if(!isset($_POST['CustomerEmail'])){$customerEmail = " ";} 
    else{$customerEmail = $_POST['CustomerEmail'];} 

    if(!isset($_POST['CustomerPhone'])){$customerPhone = " ";} 
    else{$customerPhone = $_POST['CustomerPhone'];} 

    if(!isset($_POST['CustomerFax'])){$customerFax = " ";} 
    else{$customerFax = $_POST['CustomerFax'];} 

    if(!isset($_POST['CustomerCompanyName'])){$customerCompanyName = " ";} 
    else{$customerCompanyName = $_POST['CustomerCompanyName'];} 

    if(!isset($_POST['CustomerDepartment'])){$customerDepartment = " ";} 
    else{$customerDepartment = $_POST['CustomerDepartment'];} 

    if(!isset($_POST['CustomerJobTitle'])){$customerJobTitle = " ";} 
    else{$customerJobTitle = $_POST['CustomerJobTitle'];} 

    if(!isset($_POST['CustomerStreet'])){$customerStreet = " ";} 
    else{$customerStreet = $_POST['CustomerStreet'];} 

    if(!isset($_POST['CustomerCountry'])){$customerCountry = " ";} 
    else{$customerCountry = $_POST['CustomerCountry'];} 

    if(!isset($_POST['CustomerCity'])){$customerCity = " ";} 
    else{$customerCity = $_POST['CustomerCity'];} 

    if(!isset($_POST['CustomerState'])){$customerState = " ";} 
    else{$customerState = $_POST['CustomerState'];} 

    if(!isset($_POST['CustomerPostalCode'])){$customerPostalCode = " ";} 
    else{$customerPostalCode = $_POST['CustomerPostalCode'];} 

    if(!isset($_POST['BusinessType'])){$businessType = " ";} 
    else{$businessType = $_POST['BusinessType'];} 

    if(!isset($_POST['industryType'])){$industryType = " ";} 
    else{$industryType = $_POST['industryType'];} 

    if(!isset($_POST['Employees'])){$semployees = " ";} 
    else{$employees = $_POST['Employees'];} 

    $email_message = "Please enter lead below.\n\n"; 

    $email_message .= "Lead Submitted By: $submit_name\n"; 
    $email_message .= "Company Name: $companyName\n"; 
    $email_message .= "City: $companyCity\n"; 
    $email_message .= "State: $companyState\n\n"; 

    $email_message .= "Purchase Timeframe: $timeframe\n\n"; 

    $email_message .= "Product Interest: $product\n"; 
    $email_message .= "Service Interest: $service\n"; 

    $email_message .= "Customer Information:\nCustomer Application Details and Comments: $customerApplication\n"; 
    $email_message .= "Salutation: $salutation\n"; 
    $email_message .= "First Name: $customerFirstName\n"; 
    $email_message .= "Last Name: $customerLastName\n";  
    $email_message .= "Email: $customerEmail\n"; 
    $email_message .= "Phone: $customerPhone\n"; 
    $email_message .= "Fax: $customerFax\n"; 
    $email_message .= "Job Title: $customerJobTitle\n"; 
    $email_message .= "Company: $customerCompanyName\n"; 
    $email_message .= "Department: $customerDepartment\n"; 
    $email_message .= "Address:\nStreet: $customerStreet\n"; 
    $email_message .= "City: $customerCity\n"; 
    $email_message .= "State: $customerState\n"; 
    $email_message .= "Postal Code: $customerPostalCode\n"; 
    $email_message .= "Country: $customerCountry\n\n"; 

    $email_message .= "Contact Workplace: $businessType\n"; 
    $email_message .= "Industry: $industryType\n"; 
    $email_message .= "Number of Employees: $employees\n\n"; 


// create email headers 
$headers = 'From: '.$email_to."\r\n". 
'Reply-To: '.$email_to."\r\n" . 
'X-Mailer: PHP/' . phpversion(); 
mail($email_to, $email_subject, $email_message, $headers); 
?> 

<!-- include your own success html here --> 

Thank you for submitting. 

<?php 
?> 

任何幫助,得到這個問題的底部讚賞。 謝謝。

+0

這可能是一個糟糕的殭屍。您應該獲取有關提交表單的人員/信息,並查找模式。 – 2013-05-07 13:02:14

回答

0

您已根據需要標記了幾個字段,但未檢查它們是否實際填充。就拿submit_name例如,你有它標記爲必需(*名稱),但是當表單張貼您做到以下幾點:

if(!isset($_POST['submit_name'])){$submit_name = " ";} 
else{$submit_name = $_POST['submit_name'];} 

這段代碼實際上給它一個價值" "甚至它不提供時。我想你想要做的是防止提交時提供。

//do this check for every required variable 
if (empty($_POST['submit_name']) or empty($_POST['companyName']) or empty($_POST['companyLocation']) or empty($_POST['companyCity'])) { 
    echo 'Not all required fields are set'; 

    //now there are several options. You can just end the page using exit and then the user needs to use his backbutton to get back to the form 
    //exit(); 


    //another option is to send him back yourself 
    //header('location: /form.html'); 
    //exit(); 
} 

//the submit code you have to send the mail 

旁註:

您正在使用isset即使變量張貼這將返回true,但沒有價值。也許你想檢查字符串empty(),以確保它們也包含一些東西。但不使用empty()當你想到一個數字,也可以爲0。

相關問題