我有一个注册表单,允许用户在我的网站上注册并成为会员。到目前为止,一旦他们注册了他们的详细信息,这些信息就会进入数据库,并且他们会收到一封电子邮件以表示感谢。
我正在尝试复制脚本,以便我可以发送另一封电子邮件,让我知道用户何时注册并将其发送到我的电子邮件。
我正在尝试这样做,因为发送给用户的电子邮件包含一个随机生成的 md5 哈希码,我还需要在发送给我的电子邮件中发送给我,告诉我他们已经注册。
我已经设法将两封电子邮件发送到正确的电子邮件帐户。但是,发送给我的电子邮件让我知道用户已注册也被发送给用户并且我不希望它发送给他们?
谁能建议我哪里出错了?谢谢
向用户发送电子邮件的代码:
<?php
/**
* ShuttleCMS - A basic CMS coded in PHP.
* code generator - Used for allowing a user to generate a code
*
* @author Dan <dan@danbriant.com>
* @version 0.0.1
* @package ShuttleCMS
*/
define('IN_SCRIPT', true);
// Start a session
session_start();
/*
* Generates new code and puts it on database
*/
//Generate a RANDOM MD5 Hash for a code
$random_code=md5(uniqid(rand()));
//Take the first 8 digits and use them as the password we intend to email the user
$emailcode=substr($random_code, 0, 8);
//Encrypt $emailpassword in MD5 format for the database
$registrationcode=($emailcode);
// Make a safe query
$query = sprintf("UPDATE `ptb_registrations` SET `registration_code` = '%s' WHERE email = \"$email\"",
mysql_real_escape_string($registrationcode));
mysql_query($query)or die('Could not update members: ' . mysql_error());
?>
<?php
$subjectconfirm = " Thanks for your Registration";
$headersconfirm = "To: $email\r\n";
$headersconfirm .= "From: siteindex.com <registrations@siteindex>\r\n";
$headersconfirm .= "Content-type: text/html\r\n";
$sep = sha1(date('r', time()));
$bodyconfirm = <<< EOF
(EMAIL BODY)
EOF;
// Finally, send the email
mail($email, $subjectconfirm, $bodyconfirm, $headersconfirm);
?>
然后我复制这样的代码,但替换电子邮件地址。它可以很好地发送到我的电子邮件帐户,但是它将两封电子邮件都发送给用户,我不希望他们收到给我的电子邮件。
将电子邮件发送给我的代码:
<?php
/**
* ShuttleCMS - A basic CMS coded in PHP.
* code generator - Used for allowing a user to generate a code
*
* @author Dan <dan@danbriant.com>
* @version 0.0.1
* @package ShuttleCMS
*/
define('IN_SCRIPT', true);
// Start a session
session_start();
/*
* Generates new code and puts it on database
*/
//Generate a RANDOM MD5 Hash for a code
$random_code=md5(uniqid(rand()));
//Take the first 8 digits and use them as the password we intend to email the user
$emailcode=substr($random_code, 0, 8);
//Encrypt $emailpassword in MD5 format for the database
$registrationcode=($emailcode);
// Make a safe query
$query = sprintf("UPDATE `ptb_registrations` SET `registration_code` = '%s' WHERE email = \"$email\"",
mysql_real_escape_string($registrationcode));
mysql_query($query)or die('Could not update members: ' . mysql_error());
?>
<?php
$subjectconfirm = " Thanks for your Registration";
$headersconfirm = "To: signups@siteindex.com\r\n";
$headersconfirm .= "From: siteindex.com <signups@siteindex>\r\n";
$headersconfirm .= "Content-type: text/html\r\n";
$sep = sha1(date('r', time()));
$bodyconfirm = <<< EOF
(DIFFERENT EMAIL BODY)
EOF;
// Finally, send the email
mail($email, $subjectconfirm, $bodyconfirm, $headersconfirm);
?>