<?php
//+-----------------------------------------------+//
//+ Copyright Floopo.com
//+ helper.password.php
//+ Update members password
//+-----------------------------------------------+//

defined('BASEPATH') or die('You can not directly access this file');//check its within this framework

$show_password_form = 1;

//___CHECK IF SUBMIT_______

if(isset($_POST['submit'])) {

//get current password
$result = $dbase->SelectRecord("SELECT password FROM member_profile WHERE user_name = '$env_user_name' AND account_status = 'active'");

    //process the form
     $process = new FormProcessor();
    
	//compare password on file
    ($result['password'] == Sanatize(md5($_POST['current_password'])))? $proceed1 = true : $display_notification = $lang['incorrect_password'];

    ($process->CheckFieldMatch('password, password_confirm')) ? $new_password = md5($_POST['password']) : $display_notification = $lang['password_match_error'];
    
    ($process->RequiredFields('all')) ? $proceed2 = true : $display_notification = $lang['fill_in_all'];
    
    
    //check current password
    if(($proceed1) && ($proceed2) && ($new_password)) {

        if($dbase->UpdateRecord("UPDATE member_profile SET password = '$new_password' WHERE user_name = '$env_user_name'")) {
            $display_notification = $lang['request_completed'];
        } else {
            //display error and reload post in form
            $display_notification = $lang['generic_error'];
        }
    }
}


?>