2013-07-08 46 views
0

我試圖在網上搜索類似的問題,但我只是無法得到它的工作,這讓我瘋狂。 haiz。 your_email不能通過。回聲表格值不傳遞給郵件功能

形式

echo '<form class=location_submit name="togo" action="" method="post" >'; 
    echo '<input class="user_email" type="text" name="your_email" placeholder="Enter your email here" required size="55"> <br />'; 
     echo '<input class="location_submit_button" type="image" name="button" src="images/send_location_button.png" />'; 
     echo '<input type="hidden" name="button_pressed" value="1" />'; 
echo '</form>'; 

郵件功能

if(isset($_POST['button_pressed'])) 
{ 
    $to  = $your_email; 
    $subject = "Sent from Utourpia!"; 
    $message = "Message body"; 

    $headers = "MIME-Version: 1.0" . "\r\n"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $headers .= "From: Terence Leong @ Utourpia <[email protected]>" . "\r\n"; 
    $headers .= "Reply-To: [email protected]" . "\r\n"; 
    $headers .= 'Bcc: [email protected]' . "\r\n"; 
      $headers .= "X-Mailer: PHP/" . phpversion(); 

    mail($to, $subject, $message, $headers, '-f [email protected]'); 
    echo '<p class=email_sent>Email Sent.</p>'; 
} 

事情值得大家注意的是發送電子郵件不執行,當我點擊提交按鈕,但$ your_email簡單地返回NULL: ((

回答

3

您需要從$ _POST中使用th提取值埃爾名字;

$to = $_POST['your_email']; 
+0

謝謝!它解決了我的問題,天哪,我想我需要改善我的基礎 – Architheutus