SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Check to see if a checkbox is checked

    Hey,

    I am trying to insert code into a database table depending on whether a checkbox is checked.. But i am having problems doing this..

    My code is shown below:-

    PHP Code:
        if ($checkbox[0].checked)
        {
          
    $sql "INSERT INTO users (group_id, cart_id, company_name, contact_name, nickname, position, address1, address2, address3, town, postcode, emailaddress, password, telephone, created, approved, default_cv, show_profile, registered_on, cv_bank) VALUES (1, '$cart_id', '$company_name', '$contact_name', '$nickname', '$position', '$address1', '$address2', '$address3', '$town', '$postcode', '$emailaddress', '$password', '$telephone', Now(), '1','".$_FILES['cv']['name']."', '1', '".$site->getSiteID()."', '1');";
        }
        else
        {
          
    $sql "INSERT INTO users (group_id, cart_id, company_name, contact_name, nickname, position, address1, address2, address3, town, postcode, emailaddress, password, telephone, created, approved, default_cv, show_profile, registered_on, cv_bank) VALUES (1, '$cart_id', '$company_name', '$contact_name', '$nickname', '$position', '$address1', '$address2', '$address3', '$town', '$postcode', '$emailaddress', '$password', '$telephone', Now(), '1','".$_FILES['cv']['name']."', '1', '".$site->getSiteID()."', '0');";
        } 
    My checkbox has the following code:-

    PHP Code:
    <input type="checkbox" name="checkbox" value="0"/> 
    Why does the code not seem to work..

    Thanks

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if (isset($_POST['checkbox'])) {



  3. #3
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    Thanks that worked perfectly.

    Regards


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
  •