Results 1 to 5 of 5

Thread: checking session vars

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    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

  2. #2
    scoutt
    Guest
    PHP Code:
    if (($req_var[0] = "") || ($req_var[1] = "") || ($req_var[2] = "") ){
    then do what you want...


    wouldn't that work?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    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

  4. #4
    scoutt
    Guest
    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.

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    I solved it by forgetting the array of names and just checking them each manually.

    Tedious but works, thanks anyways

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width