public static function run() { if (!($user = CookieController::readSessionCookie())) { header("Location: home"); } elseif ($_SERVER["REQUEST_METHOD"] == "POST") { if (UserDatabase::updateUser($user, $_POST)) { # First Name if (isset($_POST["firstName"])) { $firstName = $_POST["firstName"]; if (strcmp($firstName, $user->getFirstName()) !== 0) { $user->setFirstName($firstName); } } # Last Name if (isset($_POST["lastName"])) { $lastName = $_POST["lastName"]; if (strcmp($lastName, $user->getLastName()) !== 0) { $user->setLastName($lastName); } } # Email if (isset($_POST["email"])) { $email = $_POST["email"]; if (strcmp($email, $user->getEmail()) !== 0) { $user->setEmail($email); } } # Handle if (isset($_POST["handle"])) { $handle = $_POST["handle"]; if (strcmp($handle, $user->getHandle()) !== 0) { $user->setHandle($handle); } } # About if (isset($_POST["about"])) { $about = $_POST["about"]; if (strcmp($about, $user->getAbout()) !== 0) { $user->setAbout($about); } } # Password if (isset($_POST["cur-password"]) && isset($_POST["new-password"]) && isset($_POST["confirm-password"])) { $curPassword = $POST["cur-password"]; echo $curPassword; $newPassword = $POST["new-password"]; $confirmPassword = $POST["confirm-password"]; if (strcmp($curPassword, $newPassword) !== 0) { $user->setPassword($curPassword, $newPassword, $confirmPassword); } } CookieController::setSessionCookie($user); header("Location: view-profile"); } else { EditProfileView::show($user); } } else { EditProfileView::show($user); } }
public static function show($user) { $links = array("New Trip" => "new-trip", "My Trips" => "my-trips", "View my Profile" => "view-profile", "Log Out" => "log-out"); ###(HTML) ?> <!DOCTYPE html> <html> <?php MasterView::insertHead("/sm_project/css/Form.css", ""); ?> <body> <?php MasterView::insertNav($links); EditProfileView::insertContent($user); MasterView::insertFooter(null); ?> </body> </html> <?php ###(ENDHTML) }
public static function show($user) { $links = array("Home" => "home", "View my Profile" => "profile", "Build a Map" => "build-map", "Log Out" => "log-out"); ###(HTML) ?> <!DOCTYPE html> <html> <?php MasterView::insertHead(null); ?> <body> <?php MasterView::insertNav($links); EditProfileView::insertContent($user); MasterView::insertFooter(null); ?> </body> </html> <?php ###(ENDHTML) }