public function getContactById() { $person = new PersonPDO(); $this->nameDOB = $person->readById($this->personId); $address = new AddressPDO(); $this->address = $address->readAllByPersonId($this->personId); $phoneNumber = new PhoneNumberPDO(); $this->phoneNumber = $phoneNumber->readAllByPersonId($this->personId); $emailAddress = new EmailAddressPDO(); $this->emailAddress = $emailAddress->readAllByPersonId($this->personId); $image = new ImagePDO(); $this->avatar = $image->getAvatarImageByPersonId($this->personId); $this->image = $image->readAllByPersonId($this->personId); }
<?php require "controllers/LoginController.php"; require "models/Person.php"; $contact = new PersonPDO(); $stmt = $contact->readAll(); ?> <!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"> <link rel="stylesheet" href="css/bootstrap.min.css"> <link rel="stylesheet" type="text/css" href="css/main.css"/> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="js/jquery-1.12.0.min.js"></script> <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script> <link rel="stylesheet" href="css/styles.css"> <title>List of All Contacts</title> </head> <body> <?php include "includes/header.php"; ?> <div class="container"> <ol class="breadcrumb"> <li><b>List</b></li> </ol>
} } // End class PersonController if (array_key_exists('addNewContact', $_POST)) { $cPerson = new PersonController((int) $_POST['personId'], trim($_POST['lastName']), trim($_POST['firstName']), trim($_POST['middleName']), trim($_POST['aliasName']), (int) $_POST['birthMonth'], (int) $_POST['birthDay'], (int) $_POST['birthYear'], trim($_POST['note'])); $model = new PersonPDO(); if ($cPerson->nameFieldValidate()) { if (isset($_GET['action']) && $_GET['action'] === 'create') { $insertId = $model->create($cPerson); header("Location: ../profile.php?id=" . (int) $insertId); } if (isset($_GET['action']) && $_GET['action'] === 'update') { $model->updateById($cPerson); header("Location: ../profile.php?id=" . $_POST['personId']); } } elseif ($_GET['action'] === 'update') { header("Location: ../newcontact.php?id={$_POST['personId']}&action=update&validate=error"); } else { header("Location: ../newcontact.php?validate=error"); } } /* * Delete a contact and return to the list */ if (isset($_GET['action']) && $_GET['action'] == 'delete') { $deleteId = (int) $_GET['id']; $cPerson = new PersonPDO(); $cPerson->deleteById($deleteId); header("Location: ../listcontacts.php"); } $months = [" ", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
<?php require "controllers/LoginController.php"; require "models/Contact.php"; ob_start(); require "phoneEmailAddress.php"; $phoneEmailAddress = ob_get_contents(); ob_end_clean(); require "controllers/PersonController.php"; $updateForm = null; // http://localhost/contact_v1.1/newcontact.php?id=1&action=update if (isset($_GET['action']) && $_GET['action'] === 'update') { $action = "update"; $id = (int) $_GET['id']; $contact = new PersonPDO(); $updateForm = $contact->readById($id); } else { $action = "create"; } $error = NULL; if (isset($_GET['validate']) && $_GET['validate'] == "error") { $error = 1; } ?> <?php $id = NULL; if (isset($_GET['id'])) { $id = $_GET['id']; } if (isset($_POST['id'])) {
$login->verifyLogin(); if ($login->login == 0) { header("Location: login.php"); } require "models/Contact.php"; ob_start(); require "phoneEmailAddress.php"; $phoneEmailAddress = ob_get_contents(); ob_end_clean(); require "controllers/PersonController.php"; $updateForm = null; // http://localhost/contact_v1.1/newcontact.php?id=1&action=update if (isset($_GET['action']) && $_GET['action'] === 'update') { $action = "update"; $id = (int) $_GET['id']; $contact = new PersonPDO(); $updateForm = $contact->getPersonById($id); } else { $action = "create"; } $error = NULL; if (isset($_GET['validate']) && $_GET['validate'] == "error") { $error = 1; } ?> <!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">