if ($response) { echo JsonResponse::success("Profile Successfully Updated!"); exit; } else { echo JsonResponse::error("Could not update Profile. Please try again!"); exit; } } else { echo JsonResponse::error("Profile data not set"); exit; } } elseif ($intent == 'getProfile') { if (isset($_REQUEST['userid'])) { $userid = $_REQUEST['userid']; $userController = new UserController(); $profile = $userController->getUserProfile($userid); if ($profile && is_array($profile)) { echo JsonResponse::success($profile); exit; } else { echo JsonResponse::error("Could not fetch user profile. Please try again later."); exit; } } else { echo JsonResponse::error("Expected parameter not set"); exit; } } else { echo JsonResponse::error('Invalid intent!'); exit; }
<?php require_once '../_core/global/_require.php'; Crave::requireAll(GLOBAL_VAR); Crave::requireAll(UTIL); Crave::requireFiles(MODEL, array('BaseModel', 'UserModel')); Crave::requireFiles(CONTROLLER, array('AuthenticationController', 'UserController')); if (!isset($_SESSION[UserAuthTable::userid])) { header("Location: index.php"); } $userController = new UserController(); $profile = $userController->getUserProfile($_SESSION[UserAuthTable::userid]); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>PMS</title> <!-- Bootstrap core CSS --> <link href="../css/bootstrap/bootstrap.min.css" rel="stylesheet"> <!-- Custom styles for this template --> <link href="../css/master.css" rel="stylesheet"> <link href="../css/bootstrap/datepicker.css" rel="stylesheet">