Server side validation for drop downs
I have some JS validation for various forms... but thats not enough, I have a class in php that implements server side validation for the same forms... problem is that I cant get it to work for drop downs....
I can get it to validate, but not be 'sticky'..... need some help with this....
Now FIRST OFF, i should MENTION... I DID NOT write this class, it was done by a friend on Dreamweaverclub.com... Im not that advanced.... although I am heavy in some good books and definately have learned a lot, just not that much... so keep that in mind in your replies...
kudos to david powers on php solutions if he reads this... first PHP book I bought..
anyways, all help is appreciated and thank you. here is my code.,...
[CODE]<?php
session_start();
class formChecker{
function __construct(){}
function messages($k){
$mess = array(
'mess1'=>'Some of your fields are empty',
'mess2'=>'Your data has been submitted'
);
return $mess[$k];
}
function css($keys){
$style .= "#$keys{
border:solid 1px red;\n
background-color:yellow;\n
}\n\n";
return $style;
}
function checkForm($f, $r){
$req = explode(',',$r);
foreach($f as $keys=>$vals){
$_SESSION[$keys] = $vals;
}
$style = "<style>\n\n";
foreach($req as $keys){
if(isset($f[$keys]) && $f[$keys] == '???'){
$f[$keys] = '';
$valid = FALSE;
}
}
foreach($req as $keys){
if(isset($f[$keys]) && $f[$keys] == '????'){
$f[$keys] = '';
$valid = FALSE;
}
}
foreach($req as $keys){
if(isset($f[$keys]) && $f[$keys] ==''){
$style .= formChecker::css($keys);
$valid = FALSE;
}
}
$style .= "</style>";
if($valid === FALSE){
$message = formChecker::messages('mess1');
return $style."\n\n".$javaScript."\n\n<div id=\"messges\">$message</div>";
}else{
array_pop($f);
return TRUE;
}
}
}
?> [/CODE]
