Results 1 to 3 of 3

Thread: php and checkboxes

  1. #1
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php and checkboxes

    how does php check whether a checkbox has been ticked in a form? i thought of making a js function that wrote something into a hidden text box according to whether the checkbox was ticked or not, but is there a simpler way with php?

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by gusblake
    how does php check whether a checkbox has been ticked in a form?
    It doesn't, not directly anyway. The checked state of a checkbox determines if it is a successful control. Successful controls are submitted as part of the form data, whereas unsuccessful controls aren't submitted at all.

    If the name of that control is part of the $_GET or $_POST superglobals (depending on the submission method), you know it was successful. If not, then the box was unchecked.

    Code:
    if(isset($_GET['control-name'])) {
      /* Checked */
    }
    Mike

  3. #3
    Join Date
    Aug 2005
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks!

Bookmarks

Posting Permissions

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