Location: PHPKode > scripts > form create class > form-create-class/form.class.php
<?php
/* *
   * @PROGRAM NAME:  HTML Form Class
   * @FILENAME:      form.class.php
   * @PROJECT NAME:  HTML Form Class
   * @LICENSE FILE:  BSD
   * @VERSION:       1.1
   *
   * @AUTHOR_INFO
   *  @@NAME:        Stephan Maat
   *  @@EMAIL:       hide@address.com
   *  @@URL:         
   *
   * @LATEST_CHANGE: 
   *
   * @TO DO LIST:
   *  - add_checkbox
   *  - compileForm() --> gedeeltelijk af 
        Deze zal compleet veranderen, in de complieForm() zal de array worden gevuld om een form in een tabel te krijgen
        dus niet zoals dat nu gebeurd, in de add_text() enz.
   *  - sumbit_handler() --> gedeeltelijk af
   *  - submit_handler_db($con, $db, $query) --> insert, update, remove in db (versie 2.0)
   *X - javascrpt_check() --> check form elementen; mbv javascript popup melding; in de nieuwe klasse, zie laatste punt
   *X - add_javascript_check() --> geeft aan dat er een javascript geinclude moet worden; in de nieuwe klasse, zie laatste punt
   *  - method get is kinda buggy, so for now only use post. I wil fix this in version 2.0
   *  - nieuwe klasses; extends form.class.php voor het maken van forms met postcode enz.
   */

class Form extends Table{
	var $aantal_elementen;
	var $formarray;
	var $form;
	var $post_forward;
	var $javascript;        #is nog niet actief
	var $tmp;               #temp var

/* *
   * @TYPE:          constructor Method
   * @NAME:          Form
   * @DESCRIPTION:   Initializes the class variables.
   *
   * @PURPOSE:       For initialization.
   * @PARAMS:        void
   * @RETURNS:       void
   */
	function Form( ) { //constructor
		parent::Table( );
		$this->aantal_elementen = 0;
		$this->formarray = array( );
		$this->form = '';
		$this->post_forward = 0;
		$this->javascript = NULL;
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $action: To what uri should the form refer
                 $method: what method to use. Default = post. Other options are method
                 $post_forward: Default = 0 The uri string wil be encoded if 1.
                 $enctype: what encode type to use. Default = application/x-www-form-urlencoded. Other options are multipart/form-data  
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-03
   */
	function form_begin( $jscheck, $action, $method = 'post', $post_forward = 0, $enctype = 'application/x-www-form-urlencoded' ) {
		$this->formarray[0]['action'] = $action;
		$this->formarray[0]['method'] = $method;
		$this->formarray[0]['enctype'] = $enctype;
		$this->post_forward = $post_forward;
		$this->tmp = "<FORM ACTION='".$GLOBALS[PHP_SELF]."' METHOD='".$method."' ENCTYPE='".$enctype."'><INPUT TYPE='hidden' NAME='action' VALUE='".$action."'>";

		if($jscheck == 1){ $this->add_javascript_check( $name ); }
	} // end func

/**
   * Short description. 
   *
   * Detail description
   * @param      none
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     12.45 2002-03-04
   */
	function _add_element( $hidden = 0 ) {
		if( $hidden == 0 ) {
			parent::AddRow( );
		}
		return ++$this->aantal_elementen;
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      none
   * @global     none
   * @since      1.0
   * @access     public
   * @return     int
   * @update     no, please!!
   */
	function get_aantal_elementen( ) {
		return $this->aantal_elementen;
	} // end func


/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $value:
                 $size:
                 $maxlength:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-04
   */
	function add_text( $jscheck, $name, $value, $size = 20, $maxlength = 0 ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'text';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['value'] = $value;
		$this->formarray[$this->aantal_elementen]['size'] = $size;
		$this->formarray[$this->aantal_elementen]['maxlenght'] = $maxlength;
		
		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '') {
			$this->tmp .= "<INPUT TYPE='text' NAME='".$name."' VALUE='".$value."' SIZE='".$size."' MAXLENGTH='".$maxlength."'>";
		} else {
			$this->tmp = "<INPUT TYPE='text' NAME='".$name."' VALUE='".$value."' SIZE='".$size."' MAXLENGTH='".$maxlength."'>";
		}
		parent::SetCellContent ( parent::GetCurrentRow(), 1, "<B>".ucfirst($name)."</B>" );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'ALIGN', 'right' );
		parent::SetCellContent ( parent::GetCurrentRow(), 2, $this->tmp );
		parent::SetCellAttribute( parent::GetCurrentRow(), 2, 'ALIGN', 'left' );
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $radio:
                 $checked:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-04
   */
	function add_radio( $jscheck, $name, $radio, $checked ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'radio';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$i = 1;
		foreach( $radio as $value => $text ){
			$this->formarray[$this->aantal_elementen]['value'.$i] = $value;
			$this->formarray[$this->aantal_elementen]['text'.$i] = $text;
			$i++;
		}
		$this->formarray[$this->aantal_elementen]['aantal'] = $i;
		$this->formarray[$this->aantal_elementen]['checked'] = $checked;
		
		$fg = 1;
		$er = 1;
		parent::SetCellContent( parent::GetCurrentRow(), $fg, "<B>".ucfirst($name)."</B>" );
		parent::SetCellAttribute ( parent::GetCurrentRow(), $fg, 'ALIGN', 'right' );
		parent::SetCellAttribute ( parent::GetCurrentRow(), $fg, 'VALIGN', 'top' );
		parent::SetCellAttribute( parent::GetCurrentRow(), $fg, 'ROWSPAN', count( $radio ) );
		$fg++;
		foreach( $radio as $value => $text ){
			if( parent::GetCurrentRow( ) == 1 || $this->tmp != '') {
				$this->tmp .= "<INPUT TYPE='radio' NAME='".$name."' VALUE='".$value."'";
			} else {
				$this->tmp = "<INPUT TYPE='radio' NAME='".$name."' VALUE='".$value."'";
			}
			if( $er == $checked ) {
				$this->tmp .= " CHECKED>".$text;
			} else {
				$this->tmp .= ">".$text;
			}
			parent::SetCellContent( parent::GetCurrentRow(), $fg, $this->tmp );
			parent::SetCellAttribute ( parent::GetCurrentRow(), $fg, 'ALIGN', 'left' );
			if( $fg == 2 ) { $fg =1; }
			if($er < count( $radio ) ) { parent::AddRow( ); }
			$er++;
			$this->tmp = '';
		}
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $value:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-04
   */
	function add_submit( $name, $value ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'submit';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['value'] = $value;
		
		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '' ) {
			$this->tmp .= "<INPUT TYPE='submit' NAME='".$name."' VALUE='".$value."'>";
		} else {
			$this->tmp = "<INPUT TYPE='submit' NAME='".$name."' VALUE='".$value."'>";
		}
		parent::SetCellContent( parent::GetCurrentRow(), 1, $this->tmp );
		parent::SetCellColSpan( parent::GetCurrentRow(), 1, 2 );
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $value:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-04
   */
	function add_reset( $name, $value ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'reset';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['value'] = $value;
		
		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '') {
			$this->tmp .= "<INPUT TYPE='submit' NAME='".$name."' VALUE='".$value."'>";
		} else {
			$this->tmp = "<INPUT TYPE='submit' NAME='".$name."' VALUE='".$value."'>";
		}
		parent::SetCellContent( parent::GetCurrentRow(), 1, $this->tmp );
		parent::SetCellColSpan( parent::GetCurrentRow(), 1, 2 );
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name: array()
                 $value: array()
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-04
   */
	function add_submitreset( $name, $value ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'submit';
		$this->formarray[$this->aantal_elementen]['name'] = $name[1];
		$this->formarray[$this->aantal_elementen]['value'] = $value[1];
		$this->formarray[$this->aantal_elementen]['type'] = 'reset';
		$this->formarray[$this->aantal_elementen]['name'] = $name[2];
		$this->formarray[$this->aantal_elementen]['value'] = $value[2];
		
		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '') {
			$this->tmp .= "<INPUT TYPE='submit' NAME='".$name[0]."' VALUE='".$value[0]."'>&nbsp;&nbsp;";
		} else {
			$this->tmp = "<INPUT TYPE='submit' NAME='".$name[0]."' VALUE='".$value[0]."'>&nbsp;&nbsp;";
		}
		$this->tmp .= "<INPUT TYPE='reset' NAME='".$name[1]."' VALUE='".$value[1]."'>";
		parent::SetCellContent( parent::GetCurrentRow(), 1, $this->tmp );
		parent::SetCellAttribute( parent::GetCurrentRow(), 1, 'COLSPAN', 2 );
		parent::SetCellAttribute( parent::GetCurrentRow(), 1, 'ALIGN', 'center' );
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $cols:
                 $rows:
                 $text:
                 $wrap:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-04
   */
	function add_textarea( $jscheck, $name, $cols, $rows, $text = '', $wrap = 'off' ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'textarea';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['cols'] = $cols;
		$this->formarray[$this->aantal_elementen]['rows'] = $rows;
		$this->formarray[$this->aantal_elementen]['text'] = $text;
		$this->formarray[$this->aantal_elementen]['wrap'] = $wrap;
		
		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '' ) {
			$this->tmp .= "<TEXTAREA NAME='".$name."' COLS='".$cols."' ROWS='".$rows."' WRAP='".$wrap."'>".$text."</TEXTAREA>";
		} else {
			$this->tmp = "<TEXTAREA NAME='".$name."' COLS='".$cols."' ROWS='".$rows."' WRAP='".$wrap."'>".$text."</TEXTAREA>";
		}
		parent::SetCellContent ( parent::GetCurrentRow(), 1, "<B>".ucfirst($name)."</B>" );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'ALIGN', 'right' );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'VALIGN', 'top' );
		parent::SetCellContent ( parent::GetCurrentRow(), 2, $this->tmp );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 2, 'ALIGN', 'left' );
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $select:
                 $size:
                 $multiple:
                 $checked:
                 $first:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-04
   */
	function add_select( $jscheck, $name, $select, $size = 1, $multiple = 'false', $checked ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'select';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['size'] = $size;
		$this->formarray[$this->aantal_elementen]['multiple'] = $multiple;
		$i = 1;
		foreach( $select as $value => $text ){
			$this->formarray[$this->aantal_elementen]['value'.$i] = $value;
			$this->formarray[$this->aantal_elementen]['text'.$i] = $text;
			$i++;
			$this->formarray[$this->aantal_elementen]['aantal'] = $i;
		}
		$this->formarray[$this->aantal_elementen]['checked'] = $checked;

		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '') {
			$this->tmp .= "<SELECT NAME='".$name."' SIZE='".$size."'";
		} else {
			$this->tmp = "<SELECT NAME='".$name."' SIZE='".$size."'";
		}
		if($multiple == 'true'){
			$this->tmp .= " MULTIPLE>";
		} else {
			$this->tmp .= ">";
		}
		$ert = 0;
		foreach( $select as $value => $text ){
			$this->tmp .= "<OPTION VALUE='".$value."'";
			if( $multiple == 'true' ) {
				if( $checked[$ert] == 1) {
					$this->tmp .= " SELECTED>";
				} else {
					$this->tmp .= ">";
				}
			} else {
				if( $checked == $er ) {
					$this->tmp .= " SELECTED>";
				} else {
					$this->tmp .= ">";
				}
			}
			$this->tmp .= $text."</OPTION>";
			$er++;
		}
		$this->tmp .= "</SELECT>";
		parent::SetCellContent ( parent::GetCurrentRow(), 1, "<B>".substr( ucfirst( $name ), 0, -2 )."</B>" );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'ALIGN', 'right' );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'VALIGN', 'top' );
		parent::SetCellContent ( parent::GetCurrentRow(), 2, $this->tmp );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 2, 'ALIGN', 'left' );
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $value:
   * @since      1.0
   * @global     none
   * @access     public
   * @return     void
   * @update     2002-03-04
   */
	function add_hidden( $jscheck, $name, $value ) {
		$this->_add_element( 1 );
		$this->formarray[$this->aantal_elementen]['type'] = 'hidden';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['value'] = $value;
		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '') {
			$this->tmp .= "<INPUT TYPE='hidden' NAME='".$name."' VALUE='".$value."'>";
		} else {
			$this->tmp = "<INPUT TYPE='hidden' NAME='".$name."' VALUE='".$value."'>";
		}
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $value:
                 $size:
                 $maxlength:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     no
   */
	function add_password( $jscheck, $name, $value = '', $size = 20, $maxlength = 0 ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'password';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['value'] = $value;
		$this->formarray[$this->aantal_elementen]['size'] = $size;
		$this->formarray[$this->aantal_elementen]['maxlenght'] = $maxlength;

		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '') {
			$this->tmp .= "<INPUT TYPE='password' NAME='".$name."' VALUE='".$value."' SIZE='".$size."' MAXLENGTH='".$maxlength."'>";
		} else {
			$this->tmp = "<INPUT TYPE='password' NAME='".$name."' VALUE='".$value."' SIZE='".$size."' MAXLENGTH='".$maxlength."'>";
		}
		parent::SetCellContent ( parent::GetCurrentRow(), 1, "<B>".ucfirst( $name )."</B>" );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'ALIGN', 'right' );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'VALIGN', 'top' );
		parent::SetCellContent ( parent::GetCurrentRow(), 2, $this->tmp );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 2, 'ALIGN', 'left' );
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $value:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     no
   */
	function add_button( $name, $value ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'button';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['value'] = $value;
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name:
                 $src:
                 $align:
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     no
   */
	function add_image( $name, $src, $align = 'middle' ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'image';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['source'] = $src;
		$this->formarray[$this->aantal_elementen]['align'] = $align;
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   *@param       $name
                 $value
                 $accept
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     2002-03-08
   */
	function add_file( $jscheck, $name, $value, $accept , $size = 20 ) {
		$this->_add_element( );
		$this->formarray[$this->aantal_elementen]['type'] = 'file';
		$this->formarray[$this->aantal_elementen]['name'] = $name;
		$this->formarray[$this->aantal_elementen]['value'] = $value;
		$this->formarray[$this->aantal_elementen]['accept'] = $accept;
		$this->formarray[$this->aantal_elementen]['size'] = $size;
		$this->formarray[0]['accept'] = $accept;
		
		if( parent::GetCurrentRow( ) == 1 || $this->tmp != '') {
			$this->tmp .= "<INPUT TYPE='file' NAME='".$name."' VALUE='".$value."' ACCEPT='".$accept."' SIZE='".$size."'>";
		} else {
			$this->tmp = "<INPUT TYPE='file' NAME='".$name."' VALUE='".$value."' ACCEPT='".$accept."' SIZE='".$size."'>";
		}
		parent::SetCellContent ( parent::GetCurrentRow(), 1, "<B>".ucfirst( $name )."</B>" );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'ALIGN', 'right' );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 1, 'VALIGN', 'top' );
		parent::SetCellContent ( parent::GetCurrentRow(), 2, $this->tmp );
		parent::SetCellAttribute ( parent::GetCurrentRow(), 2, 'ALIGN', 'left' );
		$this->tmp = '';
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $name: array()
                 $value: array()
                 $checked: array() || int
   * @global     none
   * @since      1.1
   * @access     private
   * @return     void
   * @update     no
   */
	function add_checkbox( $jscheck, $name, $value, $checked ) {
	} //end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      none
   * @global     none
   * @since      1.0
   * @access     private
   * @return     void
   * @update     no
   */
	function submit_handler( ) {
		$post = $GLOBALS[HTTP_POST_VARS];
		$get = $GLOBALS[HTTP_GET_VARS];
		if( count( $post ) == 0 && count( $get ) == 0 ) {
			$r = 0;
		}
		elseif( count( $post ) <> 0 ) {
			for( $i=1; $i < count( $post ); $i++ ){
				switch($this->formarray[$i]['type']):
					case 'text':
						$this->formarray[$i]['value'] = $post[$this->formarray[$i]['name']];
						break;
					case 'radio':
						$this->formarray[$i]['checked'] = $post[$this->formarray[$i]['name']];
						break;
					case 'textarea':
						$this->formarray[$i]['text'] = $post[$this->formarray[$i]['name']];
						break;
					case 'select':
						$dolo = $post[substr( $this->formarray[$i]['name'], 0, -2 )];
						$c = count( $dolo );
						if( $c == 1 && $this->formarray[$i]['multiple'] != 'true' ) {
							$this->formarray[$i]['checked'] = $dolo[0];
						}else{
							$q = 0;
							for( $o = 0; $o < $this->formarray[$i]['aantal']; $o++ ) {
								if( $dolo[$q] == $o ){
									$this->formarray[$i]['checked'][$o] = 1;
									$q++;
								} else {
									$this->formarray[$i]['checked'][$o] = 0;
								}
							}
						}
						break;
					case 'submit':
						break;
					case 'reset':
						break;
					case 'hidden':
						$this->formarray[$i]['value'] = $post[$this->formarray[$i]['name']];
						break;
					case 'file':
						$this->formarray[$i]['value'] = $post[$this->formarray[$i]['name']];
						break;
					case 'image':
						$this->formarray[$i]['src'] = $post[$this->formarray[$i]['name']];
						break;
					case 'password':
						$this->formarray[$i]['value'] = $post[$this->formarray[$i]['name']];
						break;
					case 'checkbox':
						break;
				endswitch;
			}
		}
		elseif( count( $get ) <> 0 ) {
			for( $i = 1; $i < count( $get ); $i++ ) {
				switch($this->formarray[$i]['type']):
					case 'text':
						$this->formarray[$i]['value'] = $get[$this->formarray[$i]['name']];
						break;
					case 'radio':
						$this->formarray[$i]['checked'] = $get[$this->formarray[$i]['name']];
						break;
					case 'textarea':
						$this->formarray[$i]['text'] = $get[$this->formarray[$i]['name']];
						break;
					case 'select':
						$dolo = $get[substr( $this->formarray[$i]['name'], 0, -2 )];
						$c = count( $dolo );
						if( $c == 1 && $this->formarray[$i]['multiple'] != 'true' ) {
							$this->formarray[$i]['checked'] = $dolo[0];
						} else {
							$q = 0;
							for( $o = 0; $o < $this->formarray[$i]['aantal']; $o++ ) {
								if( $dolo[$q] == $o ) {
									$this->formarray[$i]['checked'][$o] = 1;
									$q++;
								} else {
									$this->formarray[$i]['checked'][$o] = 0;
								}
							}
						}
						break;
					case 'submit':
						break;
					case 'reset':
						break;
					case 'hidden':
						$this->formarray[$i]['value'] = $get[$this->formarray[$i]['name']];
						break;
					case 'file':
						$this->formarray[$i]['value'] = $get[$this->formarray[$i]['name']];
						break;
					case 'image':
						$this->formarray[$i]['src'] = $get[$this->formarray[$i]['name']];
						break;
					case 'password':
						$this->formarray[$i]['value'] = $get[$this->formarray[$i]['name']];
						break;
					case 'checkbox':
						break;
				endswitch;
			}
		}
		$string = $GLOBALS[QUERY_STRING];
		if( $string <> '' ) {
			$string = strstr( $string, '&' );
			$string = substr( $string, 1 ); 
		}
		if( count( $post ) != 0 || count( $get ) != 0 ) {
			if( count( $get ) <> 0 ) {
				$r = 2;
			} elseif( $post <> '' ) {
				$r = 1;
			}
			if( $r == 2 ) {
				$string = ereg_replace( '%5B%5D', '[]', $string );
				header( 'Location: '.$get['action'].'?'.$string );
				exit;
			} else {
				if( $this->post_forward == 1 ) {
					$string = '';
					for( $b = 1; $b < count( $this->formarray ); $b++ ) {
						if( $this->formarray[$b]['type'] != 'reset' ) {
							$name = $this->formarray[$b]['name'];
							if( substr( $name, -2 ) == '[]' ) {
								$name = substr( $name, 0, -2 );
								for( $y = 0; $y < count( $post[$name] ); $y++ ) {
										$string .= $name.'[]='.$post[$name][$y];
										if( $b+1 < count( $this->formarray ) ) { $string .= "&"; }
								}
							} else {
								$string .= $name.'='.$post[$name];
							}
							if( $b+2 < count( $this->formarray ) && $this->formarray[$b]['type'] != 'select' ) { $string .= "&"; }
						}
					}
				}
				else{ 
					$string = '';
					for( $b = 1; $b < count( $this->formarray ); $b++ ) {
						if( $this->formarray[$b]['type'] != 'reset' ) {
							$name = $this->formarray[$b]['name'];
							if( substr( $name, -2 ) == '[]' ) {
								$name = substr( $name, 0, -2 );
								for( $y = 0; $y < count( $post[$name] ); $y++ ) {
										$string .= $name.'[]='.$post[$name][$y];
										if( $b+1 < count( $this->formarray ) ) { $string .= '&'; }
								}
							} else {
								$string .= $name.'='.$post[$name];
							}
							if( $b+2 < count( $this->formarray ) && $this->formarray[$b]['type'] != 'select' ) { $string .= "&"; }
						}
					}
				$string = htmlentities( base64_encode( htmlentities( base64_encode( $string ) ) ) );
				}
				header( 'Location: '.$post['action'].'?'.$string );
				exit;
			}
		}
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      $connection
                 $query
   * @global     none
   * @since      2.0
   * @access     private
   * @return     void
   * @update     no
   */
	function submit_handler_db( $connection, $query ) {
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      none
   * @global     none
   * @since      2.0
   * @access     private
   * @return     void
   * @update     no
   */
	function add_javascript_check( ) {
		$this->javascript .= "<SCRIPT LANGUAGE='JavaScript1.1' SRC='FormCheck.js'></SCRIPT>";
	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      none
   * @global     none
   * @since      1.0
   * @access     public
   * @return     void
   * @update     no
   */
	function compileForm( ) {
		$form = '';
		$form .= $this->javascript;
		for( $i = 0; $i <= $this->aantal_elementen; $i++ ) {
			if( $i == 0 ) {
				$form .= "<FORM ACTION='".$GLOBALS[PHP_SELF]."' ";
				$form .= "ENCTYPE='".$this->formarray[$i]['enctype']."' ";
				$form .= "METHOD='".$this->formarray[$i]['method']."' ";
				if( $this->formarray[$i]['accept'] != '' ) {
					$form .= "ACCEPT='".$this->formarray[$i]['accept']."'";
				}
				$form .= "><BR>\n";
				$form .= "<INPUT TYPE='hidden' NAME='action' VALUE='".$this->formarray[$i]['action']."'>\n";
			} else {
				switch( $this->formarray[$i]['type'] ):
					case 'text':
						$form .= $this->formarray[$i]['name']."<INPUT TYPE='".$this->formarray[$i]['type']."' VALUE='".$this->formarray[$i]['value']."' ";
						$form .= "SIZE='".$this->formarray[$i]['size']."' NAME='".$this->formarray[$i]['name']."'><BR>\n";
						break;
					case 'radio':
						$form .= $this->formarray[$i]['name']."<BR>";
						$j = 1;
						while( $j < $this->formarray[$i]['aantal'] ) {
							$form .= $this->formarray[$i]['text'.$j]."<INPUT TYPE='".$this->formarray[$i]['type']."' NAME='".$this->formarray[$i]['name']."' ";
							$form .= "VALUE='".$this->formarray[$i]['value'.$j]."'";
							if( $this->formarray[$i]['checked'] == $j ) {
								$form .= " CHECKED ";
							}
							$form .= "><BR>\n";
							$j++;
						}
						break;
					case 'textarea':
					$form .= $this->formarray[$i]['name'];
						$form .= "<TEXTAREA NAME='".$this->formarray[$i]['name']."' COLS='".$this->formarray[$i]['cols']."' ";
						$form .= "ROWS='".$this->formarray[$i]['rows']."' ";
						$form .= "WRAP='".$this->formarray[$i]['wrap']."'>".$this->formarray[$i]['text']."</TEXTAREA><BR>\n";
						break;
					case 'select':
						$nameshow = substr( $this->formarray[$i]['name'], 0, -2 );
						$form .= $nameshow;
						$form .= "<SELECT NAME='".$this->formarray[$i]['name']."' SIZE='".$this->formarray[$i]['size']."'";
						if( $this->formarray[$i]['multiple'] == "false" ) {
							$form .= ">\n";
						} else {
							$form .= " MULTIPLE>\n";
						}
						$j = 0;
						if( count( $this->formarray[$i]['checked'] ) == 1 ) { 
							while( $j < $this->formarray[$i]['aantal'] ) {
								if( $j == 0 ) { 
									$tmp = $this->formarray[$i]['checked']; 
									$form .= "<OPTION VALUE='0' "; 
									if( $tmp == $j ) { 
										$form .= "SELECTED ";
									}
									$form .= ">".$this->formarray[$i]['first']."</OPTION>\n"; 
									$j++;
								}
								$tmp = $this->formarray[$i]['checked']; 
								$form .= "<OPTION VALUE='".$this->formarray[$i]['value'.$j]."'"; 
								if( $tmp == $j ) { 
									$form .= "SELECTED ";
								}
								$form .= ">".$this->formarray[$i]['text'.$j]."</OPTION>\n";
								$j++;
							}
						} else {
							while( $j < $this->formarray[$i]['aantal'] ) {
								if( $j == 0 ) { 
									if( isset( $this->formarray[$i]['checked'][$j] ) ) {
										$tmp = $this->formarray[$i]['checked'][$j];
									} else { $tmp = 1; }
									$form .= "<OPTION VALUE='0' "; 
									if( $tmp == 1 ) { 
										$form .= "SELECTED ";
									}
									$form .= ">".$this->formarray[$i]['first']."</OPTION>\n"; 
									$j++;
								}
								for( $h = 1; $h < $this->formarray[$i]['aantal']; $h++ ) {
									$tmp = $this->formarray[$i]['checked'][$j];
									$form .= "<OPTION VALUE='".$this->formarray[$i]['value'.$j]."'"; 
									if( $tmp == 1 ){
										$form .= "SELECTED";
									}
									$form .= ">".$this->formarray[$i]['text'.$j]."</OPTION>\n";
									$j++;
								}
							}
						}
						$form .= "</SELECT><BR>\n";
						break;
					case 'submit':
						$form .= "<INPUT TYPE='".$this->formarray[$i]['type']."' ";
						$form .= "VALUE='".$this->formarray[$i]['value']."' NAME='".$this->formarray[$i]['name']."'><BR>\n";
						break;
					case 'reset':
						$form .= "<INPUT TYPE='".$this->formarray[$i]['type']."' ";
						$form .= "VALUE='".$this->formarray[$i]['value']."' NAME='".$this->formarray[$i]['name']."'><BR>\n";
						break;
					case 'hidden':
						$form .= "<INPUT TYPE='".$this->formarray[$i]['type']."' ";
						$form .= "VALUE='".$this->formarray[$i]['value']."' NAME='".$this->formarray[$i]['name']."'><BR>\n";
						break;
					case 'file':
						$form .= "<INPUT TYPE='".$this->formarray[$i]['type']."' ";
						$form .= "VALUE='".$this->formarray[$i]['value']."' NAME='".$this->formarray[$i]['name']."' ";
						$form .= "ACCEPT='".$this->formarray[$i]['accept']."' ";
						$form .= "SIZE='".$this->formarray[$i]['size']."'><BR>\n";
						break;
					case 'image':
						$form .= "<INPUT TYPE='".$this->formarray[$i]['type']."' SRC='".$this->formarray[$i]['src']."' ";
						$form .= "NAME='".$this->formarray[$i]['name']."' ALIGN='".$this->formarray[$i]['align']."'><BR>\n";
						break;
					case 'password':
						$form .= "<INPUT TYPE='".$this->formarray[$i]['type']."' VALUE='".$this->formarray[$i]['value']."' ";
						$form .= "SIZE='".$this->formarray[$i]['size']."' NAME='".$this->formarray[$i]['name']."'><BR>\n";
						break;
					case 'checkbox':
						break;
				endswitch;
			}
		}
		$form .= "</FORM>\n";
		$this->form = $form;

	} // end func

/* *
   * Short description. 
   *
   * Detail description
   * @param      none
   * @global     none
   * @since      1.0
   * @access     public
   * @return     print
   * @update     no, please!!
   */
	function printForm( ) {
		echo $this->form;
	} // end func

/* *
   * @TYPE:          debugging Method
   * @NAME:          debugFormArray
   * @DESCRIPTION:   Allows you to quickly see what is located and where it's
   *                 located in your table array.
   *
   * @PURPOSE:       Prints the form array out.
   * @PARAMS:        void
   * @RETURNS:       void
   */
	function debugFormArray( ) {
		echo "<PRE>";
		print_r( $this->formarray );
		echo "</PRE>";
		parent::printTableArray( );
	} // end func

} // end class
?>
Return current item: form create class