这是我的激活电子邮件到目前为止,但我想要在确认电子邮件后向用户发送电子邮件的详细信息。电子邮件确认工作正常,但我想在确认电子邮件后向用户发送帐户详细信息。
if (isset($_GET['email']) && preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/', $_GET['email']))
{
$email = $_GET['email'];
}
if (isset($_GET['key']) && (strlen($_GET['key']) == 32))//The Activation key will always be 32 since it is MD5 Hash
{
$key = $_GET['key'];
}
if (isset($email) && isset($key))
{
// Update the database to set the "activation" field to null
$query_activate_account = "UPDATE members SET Activation=NULL WHERE(email ='$email' AND Activation='$key')LIMIT 1";
$result_activate_account = mysqli_query($dbc, $query_activate_account) ;
// Print a customized message:
if (mysqli_affected_rows($dbc) == 1)//if update query was successfull
{
echo '<div class="success">Your account is now active. You may now <a href="login.php">Log in</a></div>';
} else
{
echo '<div class="errormsgbox">Oops! Your account could not be activated. Please recheck the link if its expired or you activated before. contact us via contact@xxxxx.com</div>';
}
mysqli_close($dbc);
} else {
echo '<div class="errormsgbox">Error Occured .</div>';
}
?>
</body>
答案 0 :(得分:0)
您是否只需要在此处发送邮件:
// Print a customized message:
if (mysqli_affected_rows($dbc) == 1)//if update query was successfull
{
echo '<div class="success">Your account is now active. You may now <a href="login.php">Log in</a></div>';
mail ($email, "Activation Success", $body, $from)
}
将从您的数据中选择邮件参数,例如$body
中您想要的内容。
答案 1 :(得分:0)
Thank you so much JammyDodger231,its been fixed and working now.
here's what finally did it.
<?php
include ('database_connection.php');
if (isset($_GET['email']) && preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/', $_GET['email']))
{
$email = $_GET['email'];
}
if (isset($_GET['key']) && (strlen($_GET['key']) == 32))//The Activation key will always be 32 since it is MD5 Hash
{
$key = $_GET['key'];
}
if (isset($email) && isset($key))
{
// Update the database to set the "activation" field to null
$query_activate_account = "UPDATE members SET Activation=NULL WHERE(email ='$email' AND Activation='$key')LIMIT 1";
$result_activate_account = mysqli_query($dbc, $query_activate_account) ;
// Print a customized message:
if (mysqli_affected_rows($dbc) == 1)//if update query was successfull
{
$result = mysqli_query($dbc,"SELECT * FROM members WHERE email ='$email'");
while($row = mysqli_fetch_array($result)) {
$headers .= "BCC: xxxxxx@yahoo.com\r\n";
$headers .= 'From: My Site <no-reply@xxxxx.com>' . "\r\n";
$message = " Your Account has now been verified, Below are your Details.\n\n";
$message .= "
username: ".$row['username']."
Password: ".$row['Password']."
Account Number: ".$row['randomnumber']."
Please Ensure you keep safely.\n";
}
echo '<div class="success">Your account is now active and your Account details sent to you.
You may now <a href="login.php">Log in</a></div>';
mail ($email, "Activation Success", $message, $headers);
} else
{
echo '<div class="errormsgbox">Oops! Your account could not be activated. Please recheck the link if its expired or you activated before.</div>';
}
mysqli_close($dbc);
} else {
echo '<div class="errormsgbox">Error Occured .</div>';
}
?>