2015-09-12 46 views
0

我有一個表單沒有通過電子郵件發送回覆,我找不到原因。 '$ __'中的任何內容似乎都不能正確拉取。這只是我的電子郵件中的空白。這是一個多頁面的形式(2頁),所以我想知道這是問題,我錯過了什麼?表單回覆沒有發送電子郵件

這裏是我的代碼:

HTML:

<form name="firstForm" id="firstForm" action="submit.php" method="POST" enctype=""> 

         <div class="field"> <span class="fieldItem text"> 
         <input autocomplete="off" placeholder="Address" id="address" name="address" type="text"> 
         </span> </div> 
        </div> 
        <div class="col cols6 lastCol plm"> 
         <div class="field"> <span class="fieldItem text"> 
         <input name="unitnumber" id="unitnumber" placeholder="Unit #" type="text"> 
         </span> </div> 
        </div> 

         <select style="width: 108px; position: absolute; opacity: 0; height: 36px; font-size: 14px;" id="state" name="state" class="styled sidebr01 hasCustomSelect"> 
          <option selected="selected" value="-10">State</option> 
          <option value="AL">AL</option> 
         </select><span style="display: inline-block;" class="customSelect styled sidebr01"><span style="display: inline-block;" class="customSelectInner">State</span></span> 
         <div class="tobeSelectDisplay btn btnDefault"> <span class="selectLabel typeLowlight">State</span> <span class="selectTrigger typeLowlight"><i class="iconDownOpen"></i></span> </div> 
         </span> </span> </div> 
        </div> 

         <div class="field"> <span class="fieldItem text"> 
         <input name="zip" placeholder="Zip" id="zip" type="text"> 


        <a href="#" onClick="ValiDate();" class="mln typeDeemphasize btn btnPrimary btnLrg">Get a Personalized Report</a> 
        <noscript> 

        <div class="form_error hideFully box alert alertWarn mhs"> 
        <div class="boxBody"> 
         <p class="typeContrast mvm txtL"></p> 
        </div> 
        </div> 
        </noscript> 


           <label class="fieldLabel" for="ValuationInquiry[Full_Name]">Full Name</label> 
         <span class="fieldItem text"> 
         <input placeholder="John Smith" name="full_name" id="full_name" type="text"> 
         </span> </div> 
        </div> 
        <div class="col cols12 lastCol"></div> 

     <div class="col cols12"> 
      <div class="field"> 
      <label class="fieldLabel" for="ValuationInquiry[Last_Name]">Last Name</label> 
      <span class="fieldItem text"> 
       <input type="text" placeholder="Smith" name="last_name" id="last_name"> 
      </span> 
      </div> 
     </div> 
     <div class="col cols12 lastCol"></div> 
     </div>--> 
        <div class="line pvm2"> 
         <div class="field"> 
         <label class="fieldLabel" for="ValuationInquiry[Email_Address]">Email Address</label> 
         <span class="fieldItem text"> 
         <input placeholder="[email protected]" name="email_address" id="email_address" type="email"> 
         </span> </div> 
        </div> 
        <div class="col cols12 lastCol"></div> 
        </div> 
        <div class="line ptm2"> 
         <div class="field"> 
         <label class="fieldLabel" for="ValuationInquiry[Phone]">Phone Number</label> 
         <span class="fieldItem text"> 
         <input title="10-digit US Phone Number" name="phone" id="phone" type="text"> 
         </span> </div> 
        <div class="col cols12 lastCol"></div> 
        </div> 
       </div> 

        <input value="steptwo" name="skipsecondstep" type="hidden"> 
        <input value="Get Your Full Report" id="required_form_cta" class="typeDeemphasize btn btnPrimary" onClick="lastvalidate();" type="button"> 


    <!--</form>--> 
    </div> 
</form> 

PHP:

<?php 


$email_from = '[email protected]';//<== update the email address 
$email_subject = "Entry Received"; 
$email_body = "You have received a new message from the user $full_name.\n". 
    "Zip Code:\n $zip". 


$to = "[email protected]";//<== update the email address 
$headers = "From: $email_address \r\n"; 
$headers .= "Reply-To: $email_address \r\n"; 
//Send the email! 
mail($to,$email_subject,$email_body,$headers); 
//done. redirect to thank-you page. 
header('Location: submit.html'); 


// Function to validate against any email injection attempts 
function IsInjected($str) 
{ 
    $injections = array('(\n+)', 
       '(\r+)', 
       '(\t+)', 
       '(%0A+)', 
       '(%0D+)', 
       '(%08+)', 
       '(%09+)' 
      ); 
    $inject = join('|', $injections); 
    $inject = "/$inject/i"; 
    if(preg_match($inject,$str)) 
    { 
    return true; 
    } 
    else 
    { 
    return false; 
    } 
} 

?> 

回答

0

你從來沒有賦值$full_name$zip。他們不會奇蹟般地從您的表單中填充值。 你必須給自己分配這些值:曾經有一個特點

$full_name = $_POST['full_name']; 
$zip = $_POST['zip']; 
$email_body = "You have received a new message from the user $full_name.\n". 
"Zip Code:\n $zip". 

PHP稱爲register_globals這是在默認情況下是自動填寫表單中的變量。但是這個特性從PHP 5.3.0開始被棄用,並且從PHP 5.4.0開始被刪除。

+0

啊,那就是我所錯過的。現在就試試,謝謝。不是表格上的專業人士(如你所見)! – IVCatalina

+0

工作 - 謝謝! – IVCatalina