Checkboxes Updating Database?

Discussion in 'PHP' started by Pixel T., Jul 9, 2009.

  1. #1
    I'm kinda of confused here but maybe its only that I need some sleep. Anyways, I'm trying to code this script where I have a page for settings.

    Here is my settings page

    scode.php Looks like this

    The current number I have in the database is 0. I wanted to make it so that if its checked, the number 1 enters the database instead of the current 0.

    What am I doing wrong? Once I press submit, the number 0 disappears completely from the database.

    Thanks for the help in advance
     
    Pixel T., Jul 9, 2009 IP
  2. anthonywebs

    anthonywebs Banned

    Messages:
    657
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you forgot to disonnect from mysql
     
    anthonywebs, Jul 9, 2009 IP
  3. jam4517549

    jam4517549 Member

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Change you method to "post"
     
    jam4517549, Jul 10, 2009 IP
  4. Dirty-Rockstar

    Dirty-Rockstar Guest

    Messages:
    252
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    <form method='post' action='scode.php'>
    <input type=checkbox name='img'>
    <input type='submit' name='Submit' value='UPDATE' class='button'/></form>
    
    PHP:
    
    $change=$_POST['img'];
    if(isset($change)){
    $change='1';
    
    //put update code here. if default in field is not 0, add else $change='0'; at the end
    }
    PHP:
     
    Dirty-Rockstar, Jul 10, 2009 IP