<?php include "autoloader.php"; if (!isset($_SESSION['robo'])) { header('Location: index.php'); exit; } if (isset($_POST['logout'])) { unset($_SESSION['robo']); header('Location: index.php'); exit; } $username = $_SESSION['robo']; $controller = new profileController(); $userInfo = $controller->getUserInfo($username); if (isset($_POST['update'])) { // if any values are null, it will simply write null values to db, perfectly allowable //$firstname = $_POST['firstname']; //$lastname = $_POST['lastname']; //$email = $_POST['email']; //$cellphone = $_POST['cellphone']; $subteam = $_POST['subteam']; $fullname = $_POST['fullname']; $phone = $_POST['phone']; $gradyear = $_POST['gradyear']; $email = $_POST['email']; $pemail = $_POST['pemail']; $newUserInfo = array("UserFullName" => $fullname, "UserPhoneNumber" => $phone, "UserYear" => $gradyear, "UserParentsEmail" => $pemail, "UserEmail" => $email, "UserSubteam" => $subteam); // calls controller to input $controller->updateUserInfo($username, $newUserInfo); header('Location: profilepage.php');
include "controllers/uploadController.php"; include "controllers/loanController.php"; include "controllers/messageController.php"; include "controllers/imageController.php"; if (!empty($_GET['page'])) { switch ($_GET['page']) { case 'item': $item = new itemController(); $item->view(); break; case 'search': $search = new searchController(); $search->view(); break; case 'profile': $profile = new profileController(); $profile->view(); break; case 'settings': $settings = new settingsController(); $settings->view(); break; case 'loan': $loan = new loanController(); $loan->view(); break; case 'message': $message = new messageController(); $message->view(); break; default:
<?php // autoloader code // loads classes as needed, eliminates the need for a long list of includes at the top spl_autoload_register(function ($className) { $possibilities = array('../controllers' . DIRECTORY_SEPARATOR . $className . '.php', '../back_end' . DIRECTORY_SEPARATOR . $className . '.php', '../views' . DIRECTORY_SEPARATOR . $className . '.php', $className . '.php'); foreach ($possibilities as $file) { if (file_exists($file)) { require_once $file; return true; } } return false; }); $controller = new profileController(); $username = "******"; // test updateUserInfo // key is column name, value is the value you want to input $userInfo = array("UserFullName" => "Rohit Sanbhadti", "UserPhoneNumber" => "(408) 582-4781", "UserYear" => 2012, "UserParentsEmail" => "*****@*****.**", "UserEmail" => "*****@*****.**", "UserSubteam" => "Operational"); $controller->updateUserInfo($username, $userInfo); //$result = $controller->getUserInfo($username); //print_r($result);