Example #1
0
$page_message = "Input your username, we will send you an email to reset your password";
$user_name = "";
session_start();
// if a login session exists, make sure you redirect to the my account page.
if (check_login_session() == SUCCESS_NO_ERROR) {
    // redirect to the 'user_account' page
    // REMEMBER:
    // header() must be called before any actual output is
    // sent, either by normal HTML tags, blank lines in a file, or from PHP.
    // plus addressess must be absolute (we need to change this)
    header("Location: ../user_account/index.php");
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // Create short variable names.
        $user_name = $_POST['user_name'];
        $page_result_code = validate_reset_password_form($user_name);
        // if validation was succesful
        if ($page_result_code == SUCCESS_NO_ERROR) {
            // generate a random password.
            // update password in users database.
            // send password.
            $page_result_code = reset_password($user_name);
            if ($page_result_code == SUCCESS_NO_ERROR) {
                $page_message = "Password reset and sent to your e-mail";
                // redirect to the 'user_account' page
                // REMEMBER:
                // header() must be called before any actual output is
                // sent, either by normal HTML tags, blank lines in a file, or from PHP.
                // plus addressess must be absolute (we need to change this)
                header("Location: ../index.php");
            } else {
Example #2
0
/*
 * Created on Aug 23, 2007
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
// Page requirements
define('LOGIN_REQUIRED', false);
define('PAGE_ACCESS_LEVEL', 0);
define('PAGE_TYPE', 'PUBLIC');
// Set for every page
require 'engine/common.php';
$PasswordSent = false;
if (isset($_POST['action']) && $_POST['action'] == "Reset Password") {
    // If form does not validate, we need to return with errors.
    if ($errors = validate_reset_password_form()) {
        handle_errors($errors);
        handle_reposts();
    } else {
        // If errors occur while trying to reset password, we need to return with errors.
        if ($errors = process_reset_password_form($smarty)) {
            handle_errors($errors);
            handle_reposts();
        } else {
            $PasswordSent = true;
        }
    }
}
$smarty->assign('page_name', 'Reset Password');
$smarty->assign('PasswordSent', $PasswordSent);
// Build the page