$y){
$body .= $x != "submit" || $x != "image" || $x != "file" ? $x.": ".$y."\r\n" : "";
}
//mail($to, $subject, $body, $headers);
//NOW THAT WE ARE DONE WITH THE FORM REDIRECT
//header("Location: URL", true);
//exit();
//OR WRITE A MESSAGE
echo "Thank you. Form was submitted....";
}else{//we have error so show the form again
echo $ewd_form;
}
?>
OR
)
$f_after = as above but for closing tag (e.g. ,
) or tag
$f_validate = true OR false - true will require validation while false will NOT
$f_error_msg = ERROR mesage if $f_validate = true OTHERWISE WILL BE IGNORED
$f_xtra = xtra option to be added before closing tag (e.g onsubmit='some JS function' OR onchage='js function again' OR
accesskey="1" tabindex="1" title="title" readonly="true")
$f_src = for use with image buttons
*/
function ewd_form_fields($f_label='', $f_type='', $f_name, $f_id='', $f_size='', $f_maxlength='', $f_value='', $f_options='', $f_before='', $f_after='', $f_validate=false, $f_error_msg='', $f_xtra='',$f_src=''){
global $ewd_error_array,$ewd_error_top_array,$x_ewd_form_name;
$ewd_form_field = "";
//lets see if we have the type of the field - if not text will be used
$f_type = trim($f_type) == "" ? "text" : trim($f_type);
//convert to lower the f_name and f_id
$f_name = trim(strtolower(preg_replace("#[^0-9a-zA-Z\-\_]#","",$f_name)));
$f_id = trim($f_id) != "" ? trim(strtolower(preg_replace("#[^0-9a-zA-Z\-\_]#","",$f_id))) : $f_name;
//check the size of the field
$f_size = trim(preg_replace("#[^0-9\,]#","",$f_size)) != "" ? $f_size : (($f_type == "text" || $f_type == "password") && $f_size == "" ? "30" : "");
//maxlength
$f_maxlength = trim(preg_replace("#[^0-9]#","",$f_maxlength));
//check value from POST OR DEFAULT
$f_value = ewd_get_post_value($f_value, $f_name,$f_type);
//extra value to be added before closing tag
$f_xtra = trim($f_xtra) != "" ? " ".$f_xtra : "";
//remove spaces img src for the button
$f_src = trim($f_src) != "" ? $f_src : "";
//NOW LETS CREATE SOME FIELDS
switch ($f_type){
case "text":
$ewd_form_field = "";
break;
case "password":
$ewd_form_field = "";
break;
case "hidden":
$ewd_form_field = "";
break;
case "submit":
$ewd_form_field = "";
break;
case "image":
$ewd_form_field = $f_src != "" ?
"" :
"";
break;
case "textarea":
$f_size = stristr($f_size,",") ? explode(",",$f_size) : $f_size;
if(is_array($f_size)){
$cols = $f_size[0];
$rows = $f_size[1];
}else{
$cols = "30";
$rows = "6";
}
$ewd_form_field = "";
break;
case "checkbox":
$options = ewd_get_option_value($f_options);
if(is_array($options)){
foreach($options as $x=>$y){
$y = explode("|",$y);
$value = trim($y[0]);
$text = !empty($y[1]) ? trim($y[1]) : $value;
$ewd_form_field .= "".SPACES_CHECKBOX;
}
}else{
$y = explode("|",$y);
$value = trim($y[0]);
$text = !empty($y[1]) ? trim($y[1]) : $value;
$ewd_form_field .= "$text: ";
}
break;
case "radio":
$options = ewd_get_option_value($f_options);
if(is_array($options)){
foreach($options as $x=>$y){
$y = explode("|",$y);
$value = trim($y[0]);
$text = !empty($y[1]) ? trim($y[1]) : $value;
$ewd_form_field .= "".SPACES_RADIO;
}
}else{
$y = explode("|",$y);
$value = trim($y[0]);
$text = !empty($y[1]) ? trim($y[1]) : $value;
$ewd_form_field .= "$text: ";
}
break;
case "select":
case "select-multiple":
$options = ewd_get_option_value($f_options);
$ewd_form_field .= "";
break;
case "file":
$ewd_form_field = "";
break;
default:
$ewd_form_field = "";
}//end switch
//ADD before and after if any and remove extra spaces but exclude textarea fields
$ewd_form_field = $f_type != "textarea" ? preg_replace("#\s\s+#"," ",$f_before.$ewd_form_field.$f_after) : $f_before.$ewd_form_field.$f_after;
//SHOW TABLE FORMAT OR DIVs
if($f_type != "hidden"){
if(DIV_TBL == "table"){//we want TABLE
$ewd_form_field = "
";
}
//clear the array
unset($ewd_error_array);
unset($ewd_error_top_array);
return $error;
}
//PARSE AND CREATE FULL URL
function ewd_parse_url(){
/*** check for https ***/
$protocol = !empty($_SERVER['HTTPS']) ? 'https' : 'http';
/*** return the full address ***/
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
// END FUNCTION TO CREATE FORM FIELDS AND SHOW ERRORS
?>