/**
* contact_form: constructor
- *
- * @return void
+ *
+ * @return void
* @access public
**/
function contact_form()
{
- $this->CDB =& new GLM_DB(); // creates DB object
+ $this->CDB =& new GLM_DB(); // creates DB object
$this->set_DB_fields(); // set up the DB_fields array (configuration)
$this->set_int_array(); // interest array
$this->email = OWNER_EMAIL; // email address for mail function
- $this->table_name = 'contact'; // the contact table
+ $this->table_name = 'contact'; // the contact table
$this->styleLabel = "labelcell";// css style for the labelcell
$this->fieldcell = "fieldcell"; // css style for the field input
$this->styleLabelSmall = "smalllabelcell";// css style for the labelcell
/**
* get_form: one function to rule them all
- *
- * @return void
- * @access
+ *
+ * @return void
+ * @access
**/
function get_form()
{
/**
* set_DB_fields:
- *
- * @return
- * @access
+ *
+ * @return
+ * @access
**/
function set_DB_fields()
{
$DB_fields[]=array('name'=>'contact_method','title' => 'Preferred Contact Method', 'type' => 'radio', 'options'=>'Telephone|E-mail');
$DB_fields[]=array('name'=>'comments', 'title' =>'Message', 'type' => 'desc');
$DB_fields[]=array('name'=>'mail_ok', 'title' => 'Sign me up for the Newsletter', 'type' => 'checkbox','value'=>'t','colspan'=>4,'checked'=>1);
-
- $this->DB_fields = &$DB_fields;
+
+ $this->DB_fields = &$DB_fields;
}
/**
* set_int_array:
- *
- * @return
- * @access
+ *
+ * @return
+ * @access
**/
-
+
function set_int_array()
{
$int_array = array(
"class_registration" => "Class Registration",
"ticket_sales" => "Ticket Sales",
"no_preference" => "No Preference",
- );
+ );
$this->int_array = $int_array;
}
/**
* interest:
- * @param $field:
- *
- * @return
- * @access
+ * @param $field:
+ *
+ * @return
+ * @access
**/
function interest($field)
- {
+ {
$out .= '<table><tr>';
$count = 0;
foreach($this->int_array as $key=>$value)
{
if($count==0)
{
- $out .= '<td>';
+ $out .= '<td>';
}
$out .= '<input type="checkbox" name="interest[]" value="'.$key.'"';
if(strstr($field,$key))
{
- $out .= ' checked';
+ $out .= ' checked';
}
- $out .= '>'.$value.'<br>';
+ $out .= '>'.$value.'<br>';
if($count==5)
{
- $out .= '</td><td>';
+ $out .= '</td><td>';
}
if($count==11)
{
- $out .= '</td>';
+ $out .= '</td>';
}
- $count++;
- }
+ $count++;
+ }
$out .= "</tr></TABLE>";
return( $out );
}
/**
* display_form: shows the form and any errors in it
- * @param $error = NULL: error array
- *
+ * @param $error = NULL: error array
+ *
* @return string $out
* @access public
**/
function display_form($error=NULL)
- {
+ {
if(is_array($_POST))
{
foreach($_POST as $k=>$v)
//if($value['req'])
//{
// $out .= '</span>';
- //}
+ //}
$out .= '</td>
<td colspan="'.$value["colspan"].'" class="'.$field.'">';
$out .= GLM_TEMPLATE::build_picklist($value['name'],$GLOBALS['states_US'],$_POST['state']);
$colcount++;
}
break;
-
+
case "country":
if( $value['colspan'] == 2 || $colcount == 1 )
{
$field = $this->fieldcell;
}
//$out .= '<tr>';
-
+
$out .= "\n\t".'<td colspan="'.$value['colspan'].'" class="'.$label.'">';
if($value['req'])
{
$out .= '<span class="req">*</span> ';
}
$out.=$value['title']."</td>";
-
+
$out .= "\n\t".'<td colspan="'.$value['colspan'].'" class="'.$field.'">';
$out .= GLM_TEMPLATE::build_picklist($value['name'],$GLOBALS['country_codes'],$_POST['country']);
$out .= "</td>\n";
-
+
$out .= '</tr>';
break;
-
+
case "text":
if( $value['colspan'] == 2 || $colcount == 1 )
{
$out .= '<span class="req">*</span> ';
}
$out .= $value['title'];
- /*
+ /*
if($value['req'])
{
$out .= '</span>';
- }
+ }
*/
$out .= '</td>
<td colspan="'.$value["colspan"].'" class="'.$field.'">
{
$cols=' cols="'.$value['cols'].'"';
}
-
+
$out .= '<tr><td colspan="4" class="'.$this->fieldcell.'">'.$value[title].':
<textarea cols="30" rows="5" name="'.$value["name"].'"'.$rows.$cols.'>'.$_POST[$value["name"]].'</textarea>';
$out .= '</tr>';
$out .= '</td>';
$out .= '</tr>';
break;
-
+
case "radio":
$out .= '<tr><td colspan="2" class="'.$this->styleLabel.'" nowrap>'.$value[title].':</td>';
$rvals = explode("|",$value['options']);
-
+
// check to see if any of these vals is in the post array (did we already submit this form basically)
-
+
if(isset($_POST[$value['name']])) // it's set, so we must have something there
{
$dvar = $_POST[$value['name']];
{
$dvar = 'notset';
}
-
+
$inc = 0;
-
+
foreach($rvals as $rvK => $rvV)
{
if($dvar != 'notset')
{
if($inc == 0)
{
- $checked = ' checked';
+ $checked = ' checked';
$inc =1;
}else
{
$checked = '';
}
}
-
+
$rads .= '<input type="radio" name="'.$value['name'].'" value="'.$rvV.'"'.$checked.'> '.$rvV.'<br>'."\n";
}
-
+
$out .= '<td colspan="2" class="'.$this->fieldcell.'">';
$out.=$rads;
$out .= '</td>';
$out .= '</tr>';
break;
}
- }
+ }
$out .= '<tr align="center"><td colspan="4"><input type="submit" name="Command" value="Send"></td></tr>';
$out .= '</table>';
$out .= '</form></div>';
/**
* form_process: process the form checking for any required form values as set up in the
* DB_fields array.
- *
- * @return error array if bad
+ *
+ * @return error array if bad
* @access public
**/
function form_process()
$ban_words[] = "mime-version";
$ban_words[] = "cc\:";
$ban_words[] = "bcc\:";
-
+
if(is_array($_POST))
{
foreach($_POST as $k=>$v)
$in_vars[] = 'f';
}else
{
- $in_vars[] = addslashes(trim($_POST[$value['name']]));
+ $in_vars[] = addslashes(stripslashes(trim($_POST[$value['name']])));
}
$in_fields[] = $value['name'];
-
+
}else
{
$in_fields[] = $value['name'];
- $in_vars[] = addslashes(trim($_POST[$value['name']]));
+ $in_vars[] = addslashes(stripslashes(trim($_POST[$value['name']])));
}
}
}
{
$invars = implode("','",$in_vars);
}
- $query = "INSERT INTO ".$this->table_name."
+ $query = "INSERT INTO ".$this->table_name."
($infds)
VALUES
('$invars')";