我有一个非常标准的联系表格,其中包含姓名、电子邮件地址和电话号码的输入。除了按照标准格式将电子邮件发送到指定的电子邮件地址外,
$to = 'diysoakwells@hotmail.com';
我还想使用表单中输入的电子邮件地址中的地址向用户发送电子邮件。我正在考虑使用电子邮件输入中的 post 变量,如下所示:
$to = 'diysoakwells@hotmail.com', $email;
但没有运气。有人可以指出我正确的方向吗?使用这种方法是否存在任何安全风险?我最终的目标是为用户提供一个复选框,如果选中该复选框,则会将电子邮件副本发送给他们自己。
这是我的表格的链接
http://www.diysoakwells.com.au/cart.php
先感谢您 : )
<?php
include_once("wsp_captcha.php");
if(WSP_CheckImageCode() != "OK") {
header('location:/form-rejected.php');
die();
}
$to = 'diysoakwells@hotmail.com';
$subject = 'Order Inquiry';
$jcitems = " <p><b>ORDER:</b></p><p> " . $_POST['jcitems']."<p/>" . "<p><b>Total:</b> $" . $_POST['jctotal']."</p>";
$time = date ("h:i A");
$date = date ("l, F jS, Y");
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$headers .= 'From: inquiry@diysoakwells.com' . "\r\n" .
'Reply-To: noreply@diysoakwells.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$name = $_POST['name'];
$phone = $_POST['phone'];
$emaile = $_POST['emaile'];
$textbox = $_POST['textbox'];
$text = "<html><body><p><b>Message:</b>\n$textbox</p><p>This form was submitted on Your Web Site on \n $date at\n $time</p><p><b>Customers Email Address:</b> $emaile</p><p><b>Customers Name:</b> $name </p><p><b>Customers Phone Number:</b> $phone </p></html> </body>";
$body = $text . $jcitems;
mail($to, $subject, $body, $headers);
Header('Location: ../form-accepted.php');
?>