登録の確認後、ユーザーに別のメールを送信しようとしています。1 つは管理者ユーザー用で、もう 1 つのテキストは基本ユーザー用です。クエリされたデータに基づいて and if else ステートメントを書きましたが、両方のタイプのユーザーに両方のメールを送信します。何が間違っているのですか?
function SendBusWelcomeEmail(&$user_rec)
{
$result = mysql_query("SELECT business FROM users")
or die(mysql_error());
if($result='a') {
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->AddAddress($user_rec['email'],$user_rec['name']);
$mailer->Subject = "Welcome to ".$this->sitename;
$mailer->From = $this->GetFromAddress();
$mailer->Body ="Thank You ".$user_rec['name']." for joining xxx, \r\n\r\n".
"We are a brand new business with big ambitions. Our mission is to help the development of your skills \r\n".
"\r\n".
"Regards,\r\n".
"Webmaster\r\n".
$this->sitename;
}
if(!$mailer->Send())
{
$this->HandleError("Failed sending user welcome email.");
return false;
}
else{
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->AddAddress($user_rec['email'],$user_rec['name']);
$mailer->Subject = "Welcome to ".$this->sitename;
$mailer->From = $this->GetFromAddress();
$mailer->Body ="Hello ".$user_rec['name']."\r\n\r\n".
"Welcome! Your registration with ".$this->sitename." is completed.\r\n".
"\r\n".
"Regards,\r\n".
"Webmaster\r\n".
$this->sitename;
if(!$mailer->Send())
{
$this->HandleError("Failed sending user welcome email.");
return false;
}
}
}