登录后如何从数据库获取电子邮件?
<$
require_once ('database.php');
$username = mysql_real_escape_string ($_REQUEST["username"]);
$password = mysql_real_escape_string ($_REQUEST["password"]);
$sql = "SELECT * FROM membertb WHERE username = '" . $username . "' AND password = md5('" . $password . "')";
$result = mysql_query($sql);
$datarow = mysql_fetch_row($result);
$mailer= mysql_fetch_array($result);
$mail=$mailer['email'];
$code=rand(100000,999999);
if ($datarow) {
require 'phpmailer/PHPMailerAutoload.php';
$row=$datarow['email'];
$mail = new \PHPMailer;
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->Username = '';
$mail->Password = '
$mail->setFrom('senaidbacinovic@gmail.com', 'AceLearning');
$mail->addAddress($mail);
$mail->Subject = 'SMTP email test';
$mail->Body = "The code is $result ";
$mail->send();
} else{
$resultStr = header("Location:");
echo json_encode($resultStr);
}
?>