每天提交一次空白表格(每次相差一小时)


form submitting blank once daily (exactly one hour different each time)

我创建了一个HTML表单,使用php邮件脚本提交。我遇到的问题是,表单每天提交一次完全空白,每天一小时后。我完全卡住了,我希望有人能帮我找出我的问题。

我正在粘贴下面的代码,请注意: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 = "PI.Marketing@mt.com";
    $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
?>

任何帮助得到这个问题的底部是感激的。谢谢。

您已经按要求标记了一些字段,但没有检查它们是否实际填充。以submit_name为例,您将其标记为必需(*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()检查字符串,以确保它们也包含一些东西。但是,当您期望的数字也可以是0时,不要使用empty()