我试图在网上搜索类似的问题,但我无法让它工作,这让我疯了。 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 <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 :((
答案 0 :(得分:3)
你需要使用他们的名字从$ _POST中提取值;
$to = $_POST['your_email'];