<?php /* if(!isset($_POST['user_name'])) list_error(HTTP_Status::NOT_FOUND); */ $cols = $allowed_keys = array("user_name", "email_id", "user_creation_date", "user_update_date", "user_status", "faculty_id", "privilege_id"); $obj = new User_Master(); $keys = array_keys($obj->get_assoc_array()); $restricted_keys = array_diff($keys, $allowed_keys); foreach ($restricted_keys as $k) { unset($_POST[$k]); } if (isset($_POST['CLM5'])) { $cols = array_intersect($allowed_keys, explode(",", $_POST['CLM5'])); } $_POST['CLM5'] = implode(",", $cols); $_SERVER['REQUEST_METHOD'] = "POST"; require_once "./common.php";
} if (empty($_POST['user_password_old']) || empty($_POST['user_password']) || empty($_POST['user_password1'])) { account_error(HTTP_Status::BAD_REQUEST, "Please fill all the fields!"); } try { $dbh = new MyDbCon(); $dbh->select("User_Master"); $dbh->select->where->equalTo("user_name", $_SESSION['user_name']); $dbh->prepare(); $dbh->execute(); $user = $dbh->fetchAll()[0]; if ($user->match_password($_POST['user_password_old'])) { $newUser = $user->get_assoc_array(); $newUser['user_password'] = $_POST['user_password']; $newUser['user_password1'] = $_POST['user_password1']; $nu = new User_Master(); $suc = $nu->set_assoc_array($newUser); if (Master::isLegit($suc)) { $dbh->update($nu, array("user_name" => $_SESSION['user_name'])); $dbh->prepare(); $dbh->execute(); $final = json_encode(array("done" => true, "final" => "Password Changed Successfully!")); header('Content-Length: ' . strlen($final)); header('Content-Type: application/json'); echo $final; } else { account_error(HTTP_Status::BAD_REQUEST, "Password do not match the given specification!!"); } } else { account_error(HTTP_Status::BAD_REQUEST, "Old Password do not match"); }
<?php $dir = "../../"; $title = "Account Settings"; require_once $dir . "dashboard/includes/dash_header.php"; ?> <?php $myjs_includes[] = "ajax/form"; $myjs_includes[] = "ajax/account_settings"; $obj = new User_Master(); $guide = $obj->getGuideLines(); $class = $obj->getClass(); ?> <div id="content" class="container white-gradient"> <h1 class="form_heading purple-gradient"> Account Settings </h1> <br/> <div id="final-msg-box"></div> <form class="form-horizontal" action="" method="post" name="change_pwd" id="accntForm" enctype="multipart/form-data"> <div class="form-group <?php echo $class['user_password']; ?> "> <label class="mandatory col-lg-3 col-sm-3 control-label" for="user_password_old">Old Password:</label> <div class="col-lg-3 col-sm-4"> <input class="form-control" type="password" name="user_password_old" id="user_password_old" maxlength="<?php echo User_Master::MAX_PWD_LENGTH; ?> " autocomplete="off"/>