. */ /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once(dirname(__FILE__)."/../users.php"); $SimpleUsers = new SimpleUsers(); // This is a simple way of validating if a user is logged in or not. // If the user is logged in, the value is (bool)true - otherwise (bool)false. if( !$SimpleUsers->logged_in || !$SimpleUsers->is_admin) { header("Location: ../login.php"); exit; } // If the user is logged in, we can safely proceed. $userId = $_GET["userId"]; $user = $SimpleUsers->getSingleUser($userId); if( !$user ) die("The user could not be found..."); // Validation of input if( isset($_POST["password"]) ) { if( empty($_POST["password"]) ) $error = "You have to choose a password"; else { // Input validation is ok, set the password and then redirect $SimpleUsers->setPassword($_POST["password"], $user["userId"]); header("Location: usermanagement.php"); exit; } } // Validation end ?>