【发布时间】:2015-02-02 04:17:35
【问题描述】:
所以我有这个代码。 对于一个站点,当管理员批准您成为用户时,他会单击此链接。它会将帐户设置为活动状态,但我还想要发送电子邮件。
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
require('includes/config.php');
//collect values from the url
$memberID = trim($_GET['x']);
$active = trim($_GET['y']);
//if id is number and the active token is not empty carry on
if(is_numeric($memberID) && !empty($active)){
//update users record set the active column to Yes where the memberID and active value match the ones provided in the array
$stmt = $db->prepare("UPDATE members SET active = 'Yes' WHERE memberID = :memberID AND active = :active");
$stmt->execute(array(
':memberID' => $memberID,
':active' => $active,
));
//if the row was updated redirect the user
if($stmt->rowCount() == 1){
//redirect to login page
$stmt = $db->prepare("SELECT email FROM members WHERE memberID = :memberID");
$stmt->bindparam(':memberID', $memberID);
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_OBJ);
//send email
$to = $result->email;
$subject = "account actief";
$body = "Uw account op http://www.nol-groningen.nl is actief \n\n
Met Vriendelijke groet,\n\n
Website Admin";
$additionalheaders = "From: <".SITEEMAIL.">\r\n";
$additionalheaders .= "Reply-To: $".SITEEMAIL."";
mail($to, $subject, $body, $additionalheaders);
header('Location: login.php?action=active');
exit;
} else {
echo "Your account could not be activated.";
}
}
?>
在我放入电子邮件之前它确实有效,现在它只是进入一个空白页面。有谁知道我该如何修复它并让它发送确认电子邮件?
【问题讨论】:
-
貌似是黑名单的事情
-
尝试回显 $email;检查天气是否有一些邮件在变量中。
标签: php email admin activation