Guest User

Untitled

a guest
May 27th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. class PageController {
  2. var $person; #$person is used by the HTML page
  3. var $errs;
  4. function PageController() {
  5. $action = Form::getParameter('cmd');
  6. $this->person = new Person();
  7. $this->errs = array();
  8. if ($action == 'save') {
  9. $this->parseForm();
  10. if (!this->validate()) return;
  11. NewsletterLogic::subscribe($this->person);
  12. header('Location: confirmation.php');
  13. exit;
  14. }
  15. }
  16. function parseForm() {
  17. $this->person->name = Form::getParameter('name');
  18. $this->person->birthdate = Util::parseDate(Form::getParameter('birthdate');
  19. ...
  20. }
  21. function validate() {
  22. if ($this->person->name == '') $this->errs['name'] = FORM_MISSING;
  23. #FORM_MISSING is a constant
  24. ...
  25. return (sizeof($this->errs) == 0);
  26. }
  27. }
Add Comment
Please, Sign In to add comment