2013-05-07 5 views
0

Я создал HTML-форму, которая отправляется с использованием сценария php mail. Проблема, с которой я сталкиваюсь, заключается в том, что форма отправляется полностью пустой раз в день, ровно через час каждый день. Я полностью застрял, и я надеюсь, что кто-то может помочь определить мою проблему.форма отправки пустой один раз в день (раз в один час каждый раз)

Я вставляю код ниже, обратите внимание: конечное местоположение для 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

Это, вероятно, плохой бот. Вы должны захватить информацию о том, кто/что подал форму, и искать шаблон. –

ответ

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, которая возвращает истину, даже если переменная размещена, но без значения. Возможно, вы хотите проверить строки с помощью empty(), чтобы убедиться, что они также содержат что-то. Но не используйте empty(), когда вы ожидаете число, которое также может быть 0.

Смежные вопросы