我的用户注册后,我希望他们从我正在运行的本地主机服务器接收电子邮件。下面相同的脚本在付费托管上工作正常但是当我尝试在我的本地主机上运行它时,我收到以下错误:
注意:未定义的变量:标题 第60行/Applications/XAMPP/xamppfiles/htdocs/site/newuser.php
else {
echo "<br /><center>** CHECK SPAM **. We have sent a activation code to your email,
you will not be able to login follow the steps.</center>";
$name = $_POST['name'];
$password = sha1(md5($_POST['password']));
$email = $_POST['email'];
$cwid = $_POST['cwid'];
$verificationCode = md5(uniqid($_POST['name'], true));
(LINE 60) $headers .= "Reply-To: Kwame Project<d1kwame@gmail.com>\r\n";
$headers .= "Return-Path: Kwame Project<d1kwame@gmail.com>\r\n";
$headers .= "From: Kwame Project<d1kwame@gmail.com>\r\n";
$headers .= "Organization: Kwame\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
$message = "Hello " . $name . "! It appears you have registed an
account with us.\r\nIn order to complete your registration, you must
click the link below.\r\n" . $siteURL . "activate.php?
code=".$verificationCode."\r\nThank you!";
$message = wordwrap($message, 70, "\r\n");
mail($email, 'Activate Your Account', $message, $headers);
$InsertUser = $database->prepare("INSERT INTO students (`cwid`, `name`,
`password`, `activated`, `activation_code`, `email`, `user_group`)
VALUES (?, ?, ?, ?, ?, ?, ?)");
$InsertUser->execute(array($cwid, $name, $password, 0,
$verificationCode, $email, 0));
header('Refresh: 3; url=login.php');
}
}
答案 0 :(得分:1)
这样的事情:
...........
$headers = '';
(LINE 60) $headers .= "Reply-To: Kwame Project<d1kwame@gmail.com>\r\n";
$headers .= "Return-Path: Kwame Project<d1kwame@gmail.com>\r\n";
$headers .= "From: Kwame Project<d1kwame@gmail.com>\r\n";
$headers .= "Organization: Kwame\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
$message = "Hello " . $name . "! It appears you have registed an
account with us.\r\nIn order to complete your registration, you must
click the link below.\r\n" . $siteURL . "activate.php?
code=".$verificationCode."\r\nThank you!";
$message = wordwrap($message, 70, "\r\n");
mail($email, 'Activate Your Account', $message, $headers);
$InsertUser = $database->prepare("INSERT INTO students (`cwid`, `name`,
`password`, `activated`, `activation_code`, `email`, `user_group`)
VALUES (?, ?, ?, ?, ?, ?, ?)");
$InsertUser->execute(array($cwid, $name, $password, 0,
$verificationCode, $email, 0));
header('Refresh: 3; url=login.php');
答案 1 :(得分:0)
尝试在第60行之前初始化$ headers变量:
$headers = '';