FormWizard.class.php

  1. <?php
  2. /**
  3.  * @package com.skillfulweb.FormWizard
  4.  * class FormWizard
  5.  * FormWizard.class.php
  6.  */
  7. class FormWizard {
  8.  
  9. private $formName = "";
  10.  
  11. public function __construct($formName) {
  12. $this->formName = $formName;
  13. // Make sure session has been started. Needed in PHP 5.3+.
  14. // Using @ to suppress notice if the session was already started.
  15. if(!isset($_SESSION[$formName])) {
  16. $_SESSION[$formName] = array();
  17. echo "Form wizard session initialized.";
  18. }
  19. }
  20.  
  21. public function __set($name, $value) {
  22. $_SESSION[$this->formName][$name] = $value;
  23. }
  24.  
  25. public function __get($name){
  26. if(isset($_SESSION[$this->formName][$name])) {
  27. return $_SESSION[$this->formName][$name];
  28. } else {
  29. return null;
  30. }
  31. }
  32.  
  33. }
  34.  
  35. ?>