Copy link to clipboard
Copied
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]
Copy link to clipboard
Copied
Deaf Boyz Audio.com wrote:
Now FIRST OFF, i should MENTION... I DID NOT write this class, it was done by a friend on Dreamweaverclub.com...
Just wondering why your friend on Dreamweaverclub.com isn't helping you with this. You have provided the code for a custom PHP class that doesn't contain any comments or indication of the values expected to be passed to the checkForm() method. Most of the code is fairly straightforward, but there are some aspects of it that aren't very clear. Without knowing how the class is meant to be used, it's rather difficult to offer any advice on how to improve it. That's why I think the first person to turn to for help is the person who created it.
Copy link to clipboard
Copied
Yes, that was my first stop... I asked and I have not been answered.... for almost 2 weeks now.
This code is also at the top of my form....
// create object
$formObj = new formChecker;
// define required fields using ID value of field
$RequiredFields = 'name,e_mail,state,age,sent';
// test if form has been posted
if((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frmFeedback")){
//run sql here
if($valid === TRUE){
Now im not exactly sure but I believe this is how it works....
It takes the required fields named by their id and checks for them being filled out, it they are not then it adds them to an array and styles the field with the $style variable plus puts $mess1 at the top.
For each filled out field it takes the data and starts a session with that data in it to make the form fields sticky...
I can get the drop downs to validate but i can not make them sticky.... its out of my league...
The part in my original code in the first post where I have the loops with the '???' and '????'. I added that myself, to make the initial value in the drop downs not satisfy the validation.... I have since figured out a better way and shall take that pary out... besides it might be making them not sticky.... not sure, not that knowledgable.
I do know there are a LOT of very knowledgable people on Adobe forums and I just need this little bit of help... this script although custom is based on the same PHP programming language that we all use... Hopefully someone will be able to lend a hand, i dont have many options left and have been struggling with serverside validation for long enough now.
thanks
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more