Skip to content

Instantly share code, notes, and snippets.

@xiplias
Created May 31, 2010 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiplias/420178 to your computer and use it in GitHub Desktop.
Save xiplias/420178 to your computer and use it in GitHub Desktop.
class PageController {
var $person; #$person is used by the HTML page
var $errs;
function PageController() {
$action = Form::getParameter('cmd');
$this->person = new Person();
$this->errs = array();
if ($action == 'save') {
$this->parseForm();
if (!this->validate()) return;
NewsletterLogic::subscribe($this->person);
header('Location: confirmation.php');
exit;
}
}
function parseForm() {
$this->person->name = Form::getParameter('name');
$this->person->birthdate = Util::parseDate(Form::getParameter('birthdate');
...
}
function validate() {
if ($this->person->name == '') $this->errs['name'] = FORM_MISSING;
#FORM_MISSING is a constant
...
return (sizeof($this->errs) == 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment