/** * Override default validation * @see Phreezable::Validate() */ public function Validate() { // example of custom validation // $this->ResetValidationErrors(); // $errors = $this->GetValidationErrors(); // if ($error == true) $this->AddValidationError('FieldName', 'Error Information'); // return !$this->HasValidationErrors(); return parent::Validate(); }
<?php if (isset($_POST['submitContact'])) { $contact = new ContactDAO($_POST); if ($contact->validate()) { $contact->addContact(); unset($_POST); $html = "<div class='JSLITE_errorBox'>" . "<p>Thank you for your submission.</p>" . "<p>If you requested it, I will contact you shortly.</p>" . "</div>"; $disable = 1; //disable the submit button; } else { $errors = $contact->getErrors(); $html = "<div class='JSLITE_errorBox'>" . "<p>The following form elements failed validation:</p>" . "<ol class='JSLITE_errorList'>"; foreach ($errors as $value) { $html .= "<li>" . $value . "</li>"; } $html .= "</ol></div>"; //define some variables that will set the values of form fields; if (isset($_POST['full_name'])) { $full_name = htmlentities($_POST['full_name']); } if (isset($_POST['email'])) { $email = htmlentities($_POST['email']); } if (isset($_POST['website'])) { $website = htmlentities($_POST['website']); } if (isset($_POST['message'])) { $message = htmlentities($_POST['message']); } }
<?php function __autoload($class) { require_once "/home/benjamin/public_html/lib/php/classes/{$class}.php"; } session_start(); if ($_POST['submit']) { if ($_POST['username'] != "" && $_POST['password'] != "") { $contact = new ContactDAO($_POST); // set the username session variable; if ($contact->authenticateUser()) { $_SESSION['username'] = $_POST['username']; header("Location: menu.php"); } else { echo "LOGIN FAILED"; } } } if ($_GET['action'] == "logout") { session_unset(); session_destroy(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Admin :: www.benjamintoll.com</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> fieldset {
<?php function __autoload($class) { require_once "/home/benjamin/public_html/lib/php/classes/{$class}.php"; } if ($_POST['submit']) { if ($_POST['username'] != "" && $_POST['password'] != "") { $contact = new ContactDAO($_POST); $contact->createUser(); header("Location: index.php"); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Admin :: www.benjamintoll.com</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> fieldset { margin: 30px auto; width: 310px; } label { clear: left; float: left; margin-left: 10px; padding: 5px 0; text-align: right; width: 150px;