<?php require_once "bookmark_fns.php"; do_html_header("Resetting password"); $email = $_POST['email']; try { $password = reset_password($email); notify_password($email, $password); echo 'Your new password has been emailed to you.<br />'; } catch (Exception $e) { echo $e->getMessage() . ' please try again.'; } do_html_url('login.php', 'Login'); do_html_footer();
$errors[] = 'You must provide a valid email.'; } // Check if email exits in the database. $SQL_QUERY = $db->query("select * from users where email = '{$email}'"); $email = mysqli_fetch_assoc($SQL_QUERY); $emailCount = mysqli_num_rows($SQL_QUERY); // If email is less than 1, then that email does not exist in the database. if ($emailCount < 1) { $errors[] = 'That email doesn\'t exist in the database.'; } // check errors if (!empty($errors)) { echo display_errors($errors); } else { $password = reset_password($username); notify_password($username, $password); $_SESSION['success_flash'] = 'Your new password has been emailed to you. Make sure to check your spam folder in your email. <a href="SignIn.php" id="SignIn-her">SignIn here</a>'; header('Location: ForgotPass.php'); } } ?> <div class="container"> <h3 id="SignUp-header"><div class="header">Forgot Password.</div></h3> <div id="SignUp-form-container"> <form action="ForgotPass.php" method="post"> <div class="form-group">
require_once 'require.php'; $new_password = generatePassword($length = 9, $strength = 0); if ($new_password == false) { die('Could not generate new password'); } $username = $_POST['username']; $email = $_POST['email']; if (!filled_out($_POST)) { die('You must enter your username and email!!!- Try again'); exit; } //Check to make sure user exists and knows both username and password include 'db_fns.php'; $query = "UPDATE usertable SET passwd=sha1('" . $new_password . "') WHERE username ='******' AND email='" . $email . "'" or die . mysqli_error(); $result = mysqli_query($conn, $query); header("refresh:15;url=index.php"); echo $username . "<br />"; echo $email . "<br />"; echo "Your new password is " . $new_password . "<br />"; if (!$result) { die('Did not work'); exit; } else { if ($result) { echo "You data was updated with " . $new_password; echo "Your page will be refreshed in 15 seconds!"; } } notify_password($username, $new_password);