php从数据库获取电子邮件

时间:2019-02-06 16:57:35

标签: php mysql database mysql-workbench

登录后如何从数据库获取电子邮件?

<$
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);
}
?>

0 个答案:

没有答案