4 var $values = array(); //Holds submitted form field values
5 var $errors = array(); //Holds submitted form error messages
6 var $num_errors; //The number of errors in submitted form
8 /* Class constructor */
11 * Get form value and error arrays, used when there
12 * is an error with a user-submitted form.
14 if(isset($_SESSION['value_array']) && isset($_SESSION['error_array'])){
15 $this->values
= $_SESSION['value_array'];
16 $this->errors
= $_SESSION['error_array'];
17 $this->num_errors
= count($this->errors
);
19 unset($_SESSION['value_array']);
20 unset($_SESSION['error_array']);
23 $this->num_errors
= 0;
28 * setValue - Records the value typed into the given
29 * form field by the user.
31 function setValue($field, $value){
32 $this->values
[$field] = $value;
36 * setError - Records new form error given the form
37 * field name and the error message attached to it.
39 function setError($field, $errmsg){
40 $this->errors
[$field] = $errmsg;
41 $this->num_errors
= count($this->errors
);
45 * value - Returns the value attached to the given
46 * field, if none exists, the empty string is returned.
48 function value($field){
49 if(array_key_exists($field,$this->values
)){
50 return htmlspecialchars(stripslashes($this->values
[$field]));
57 * error - Returns the error message attached to the
58 * given field, if none exists, the empty string is returned.
60 function error($field){
61 if(array_key_exists($field,$this->errors
)){
62 return "<font size=\"2\" color=\"#ff0000\">".$this->errors
[$field]."</font>";
68 /* getErrorArray - Returns the array of error messages */
69 function getErrorArray(){