Example #1
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', true);
define('PAGE_ACCESS_LEVEL', 1);
define('PAGE_TYPE', 'USER');
// Set for every page
require 'engine/common.php';
$PasswordChanged = false;
if (isset($_POST['action']) && $_POST['action'] == "Change Password") {
    // If form does not validate, we need to return with errors.
    if ($errors = validate_change_password_form()) {
        handle_errors($errors);
    } else {
        // If errors occur while trying to change password, we need to return with errors.
        if ($errors = process_change_password_form($smarty)) {
            handle_errors($errors);
        } else {
            $PasswordChanged = true;
        }
    }
}
$smarty->assign('page_name', 'Change Password');
$smarty->assign('PasswordChanged', $PasswordChanged);
// Build the page
require 'global_begin.php';
$smarty->display('user/changepassword.tpl');
Example #2
0
$new_password2 = "";
/*
 * Page script logic
 */
session_start();
$page_result_code = check_login_session();
// if a login session exists
if ($page_result_code == SUCCESS_NO_ERROR) {
    // first, check if we received a post request.
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // Create short variable names.
        $user_name = $_SESSION['validated_user'];
        $old_password = $_POST['old_password'];
        $new_password = $_POST['new_password'];
        $new_password2 = $_POST['new_password2'];
        $page_result_code = validate_change_password_form($old_password, $new_password, $new_password2);
        if ($page_result_code == SUCCESS_NO_ERROR) {
            $page_result_code = change_password($user_name, $old_password, $new_password);
            if ($page_result_code == SUCCESS_NO_ERROR) {
                $page_message = "changed password succesfully";
                // redirect to the 'my_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 {
                handle_result_code($page_result_code, $page_message);
            }
        } else {
            handle_result_code($page_result_code, $page_message);