getDisplayName()); Core::addBreadcrumb("/account/users/$id/edit", $page_title); $submit = http::value("submit"); if($submit) { try { Core::validateCSRFToken($submit); $form_exception = new FormException; // Password $password = http::value("password"); $password_confirm = http::value("password_confirm"); if($password != $password_confirm) $form_exception->addError("Passwords do not match."); if($password) { $user->password = password_hash($password, PASSWORD_DEFAULT, ["cost" => 14]); } $user->title = http::value("title", "trim"); $user->first_name = http::value("first_name", "trim"); $user->last_name = http::value("last_name", "trim"); $user->date_of_birth = http::value("date_of_birth", "trim"); $user->phone = http::value("phone", "trim"); $user->gender = http::value("gender", "trim"); if($password && !User::validatePassword($password)) $form_exception->addError("Password must be at least 6 characters in length and contain at least one lowercase, uppercase, number and special character."); if(empty($user->email)) $form_exception->addError("Email address is invalid."); if(empty($user->title)) $form_exception->addError("Title is required."); if(empty($user->first_name)) $form_exception->addError("First name is required."); if(empty($user->last_name)) $form_exception->addError("Last name is required."); if(empty($user->date_of_birth)) $form_exception->addError("Date of birth is required."); if(empty($user->phone)) $form_exception->addError("Mobile number is required."); if($form_exception->hasErrors()) throw $form_exception; $success = $user->commit(); Core::addAlert("success", "User updated successfully."); HTTP::redirect("/account/users/$id"); } catch(FormException $e) { $e->generateAlerts(); } catch(Exception $e) { Core::addAlert("danger", $e->getMessage()); } } View::includeOnce("header", compact("page_title")); View::include("user_edit_form", compact("user")); View::includeOnce("footer"); ?>