27 lines
870 B
PHP
27 lines
870 B
PHP
<?php
|
|
// include database and object files
|
|
include_once '../config/init.php'; // contains $db
|
|
include_once '../config/error.php';
|
|
include_once '../objects/db_user.php';
|
|
|
|
// prepare user object
|
|
$user = new User($db);
|
|
$user->id = isset($_POST['userId']) ? $_POST['userId'] : -1;
|
|
$user->username = isset($_POST['username']) ? $_POST['username'] : '';
|
|
|
|
// ensure userId is passed in $_POST parameters
|
|
if ($user->id <= 0 && $user->username == '')
|
|
trigger_error( missing_parameter_error("userId or username") );
|
|
|
|
if (isset($_POST['password']))
|
|
$user->password = base64_encode($_POST['password']);
|
|
else trigger_error( missing_parameter_error("password") );
|
|
|
|
// load all info for this user id
|
|
if ($user->resetPassword())
|
|
{
|
|
$user_arr = $user->getResultArray(true, "Password_Updated");
|
|
print_r(json_encode($user_arr)); // OK
|
|
}
|
|
else trigger_error("Error_Updating_Password");
|
|
?>
|