简体   繁体   中英

SQL result not being sent in email

I have a forgot password php page that sends the user his password if his email is in the database. The code is working but the password in the sent email is blank. I think it's cause I haven't converted it to a string but I cant find how to do so. Also I have salted the passwords in the database, is this affecting anything?

The salt:

 <?php $salt1 = "qm&h*"; $salt2 = "pg!@"; $token = hash('ripemd128', "$salt1$pass$salt2"); ?> 

The forgot password php page:

 <?php $error = $email = ""; if (isset($_POST['email'])) { $email = sanitizeString($_POST['email']); if ($email == "") $error = "Not all fields were entered<br>"; else if (!filter_var($email, FILTER_VALIDATE_EMAIL)) $error='Email is invalid'; else { $resultE = queryMySQL("SELECT email FROM users WHERE email='$email'"); $result_pass = queryMysql("SELECT * FROM users WHERE email='$email'"); $row = $result_pass->fetch_array(MYSQLI_ASSOC); $user_pass = $row['[pass]']; if ($resultE->num_rows == 0) { $error = "<span class='error'>Email error</span><br><br>"; }else { $mail_to = $email; $subject = 'This is your registered password '; $body_message = 'Password: '."\\n\\n".$user_pass; //convert to string $mail_status = mail($mail_to, $subject, $body_message); if(isset($_SESSION['url'])) $url = $_SESSION['url']; else $url = "../../index.php"; header("Location:$url"); } } } ?> 

我已经替换了错误代码

 $user_pass = $row['pass']; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM