0

我试图在网上搜索类似的问题,但我无法让它工作,它让我发疯。海兹。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 <terence@utourpia.me>" . "\r\n"; 
    $headers .= "Reply-To: terence@utourpia.me" . "\r\n";
    $headers .= 'Bcc: terence@popby.me' . "\r\n";
            $headers .= "X-Mailer: PHP/" . phpversion();

    mail($to, $subject, $message, $headers, '-f terence@utourpia.me');
    echo '<p class=email_sent>Email Sent.</p>';
}

值得注意的是,当我单击提交按钮时,发送的电子邮件确实会执行,但 $your_email 只会返回 NULL :((

4

1 回答 1

3

您需要使用名称从 $_POST 中提取值;

$to = $_POST['your_email'];
于 2013-07-08T14:36:02.647 回答