Jump to content

Calculating checkbox values


danieljgraham

Recommended Posts

Hi There,

 

I just wanted to share a really cool way of managing check boxes. For instance you could use them for user access functions etc

 

For you to read the values in PHP, this returns a true or false (1 or 0)

 


      public function checkAccess($required) { // The value of the box your after....e.g......64
            $m_access = $_SESSION['login_Access']; // This is where you store the checkbox value
            if ($required == 1 ) {
                  if($m_access & $required) {
                        return true;
                  }
            } else {			
                  if(($m_access & $required) / $required == 1) {
                        return true;
                  }
            }
      return false;
      }

 

or

 


      if((1024 & 64) / 64 == 1) {
            return true;
      }


 

This function will always return a unique value as per the box checked.

 

Hope people find it useful.

 

Daniel

 

[attachment deleted by admin]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.