Results 1 to 3 of 3

Thread: [RESOLVED] Error on $_POST checkbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Resolved [RESOLVED] Error on $_POST checkbox

    If I tick the checkbox everything is fine, it only errors with an unchecked checkbox on line

    $merit = $_POST['merit'];

    It's not recognising the 'merit' form value, sorry don't have the error message, if left unticked

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Error on $_POST checkbox

    HTML forms don't send the values of checkbox inputs that aren't checked. Try using isset() to make sure you have data before setting it:
    Code:
    $merit = 0;
    if(isset($_POST['merit'])){
      $merit = $_POST['merit'];
    }
    
    //or...
    
    $merit = (isset($_POST['merit'])) ? $_POST['merit'] : 0;

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Re: Error on $_POST checkbox

    Thanks mate, works like a brought one

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