-
checking session vars
I'm trying to do some validation with form data passed to a script and stored in session vars, but not getting very far
I have an array of session var names I want to check to make sure they aren't empty
PHP Code:
$req_vars = array("field1", "field2", "field3");
How can I get PHP to check each of those fields ensuring each has a value? This has really got me stumped. I'm using the $_SESSION thing BTW
Thanks
-
PHP Code:
if (($req_var[0] = "") || ($req_var[1] = "") || ($req_var[2] = "") ){
then do what you want...
}
wouldn't that work?
-
I don't think so since that would check $req_var[0] to see if it's empty rather than $req_var[0]'s value (being "field1")
Not as easy as it looks methinks
-
so field1 is the variable name in the session too?
well, for whatever the name of the session variable is can't you just do this.
if (session_registered(field1)) {
maybe I am confused here. what is the name of the session variable that is suppose to be in the session.
-
I solved it by forgetting the array of names and just checking them each manually.
Tedious but works, thanks anyways :cool: