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); }
$id = (int) $_GET['id']; } elseif (!isset($_GET['id'])) { header("Location: listcontacts.php"); } /* ob_start(); require("avatarNameDOB.php"); $avatarNameDOB = ob_get_contents(); ob_end_clean(); */ ob_start(); require "phoneEmailAddress.php"; $phoneEmailAddress = ob_get_contents(); ob_end_clean(); require_once 'models/EmailAddress.php'; $email = new EmailAddressPDO(); $emailData = null; $action = null; if (isset($_GET['update']) && $_GET['update'] === '') { header("Location: profile.php?id=" . $_GET["id"]); } if (isset($_GET['update'])) { $action = "update"; $updateId = (int) $_GET['update']; $emailData = $email->readById($updateId); if ($emailData == null) { header("Location: profile.php?id=" . $_GET["id"]); } } else { $action = "create"; }
if (preg_match("/\\A[a-z0-9]+([-._][a-z0-9]+)*@([a-z0-9]+(-[a-z0-9]+)*\\.)+[a-z]{2,4}\\z/", strtolower($this->_emailAddress)) && preg_match('/^(?=.{1,64}@.{4,64}$)(?=.{6,100}$).*/', strtolower($this->_emailAddress))) { $emailFieldValidate = 1; } return $emailFieldValidate; } } // End PhoneNumberController if (array_key_exists('addEmail', $_POST)) { $cEmail = new EmailAddressController((int) $_POST['emailId'], trim($_POST['personId']), trim($_POST['emailAddress']), (int) $_POST['type'], trim($_POST['note'])); if ($cEmail->emailFieldValidate()) { $model = new EmailAddressPDO(); if (isset($_GET['action']) && $_GET['action'] === 'create') { $model->create($cEmail); header("Location: ../profile.php?id=" . $_POST['personId']); } if (isset($_GET['action']) && $_GET['action'] === 'update') { $model->updateById($cEmail); header("Location: ../profile.php?id=" . $_POST['personId']); } } elseif ($_GET['action'] === 'update') { header("Location: ../email.php?id={$_POST['personId']}&action=update&validate=error&update={$_POST['emailId']}"); } else { header("Location: ../email.php?id={$_POST['personId']}&validate=error"); } } if (isset($_GET['action']) && $_GET['action'] == 'delete') { $deleteId = (int) $_GET['id']; $model = new EmailAddressPDO(); $model->deleteById($deleteId); header("Location: ../profile.php?id=" . $_GET['personId']); }