如此处所示,我有一个包含电子邮件的表单,当用户在电子邮件表单中输入电子邮件并点击提交时,我都会收到一封电子邮件,其中包含表单中包含的所有数据以及用户输入的内容会收到我的电子邮件,任何人都知道如何修复我的代码以使这种双重方式有效吗?
<?php
if (isset($_POST["send"])){
$emailTo="myemail@gmail.com";
$subject="Thank you for seeking us for help";
$name=($_POST['fname']);
$address=($_POST['address']);
$email=($_POST['email']);
$phone=($_POST['phone']);
$message=($_POST['message']);
$body="Name:$name \r\n Address:$address \r\n Email: $email \r\n
Phone: $phone \r\n Message: $message";
if (mail($emailTo,$subject,$body,$headers)){
header('Location:Thankyou.php');
exit;
}else{
echo "failure";
}
}else{
}
if (isset($_POST["send"])){
$email2=($_POST['email']);
$emailTo="$email2";
$subject="Thank you for emailing us";
$body="Thank you";
mail($emailTo,$subject,$body,$headers);
}
?>
忽略标题。