Checked / unchecked error messages

Discussion in 'PHP' started by qwikad.com, Nov 25, 2012.

  1. #1
    On one of my pages if both checkboxes are checked this error message will show up:




    
    
    
                if ($_POST['promote']['multicity_co'] && $_POST['promote']['multicity_cf'])
                    $err .= "&bull; please, select only ONE paid promotion<br>";
    
    
    
    Code (markup):

    My question is, what code should I use to give an error message if NONE of the checkboxes are checked?


    Thank you in advance.
     
    qwikad.com, Nov 25, 2012 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
  3. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    7,373
    Likes Received:
    1,720
    Best Answers:
    31
    Trophy Points:
    475
    #3
    EricBruggema thank you for your help.
     
    qwikad.com, Nov 26, 2012 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    I'd change your existing code so that checking one checkbox unchecks the other.
     
    Rukbat, Nov 27, 2012 IP
  5. Zoti Media Group

    Zoti Media Group Notable Member

    Messages:
    1,599
    Likes Received:
    113
    Best Answers:
    2
    Trophy Points:
    265
    Digital Goods:
    2
    #5
    This is that error msg if non of boxes are checked.
     
    Zoti Media Group, Nov 27, 2012 IP
  6. purplesoft

    purplesoft Member

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    43
    #6
    You can use isset function to check whether variable is set or not for the checkboxes when you dont check $_POST wont read variable so you should use isset function
     
    purplesoft, Nov 28, 2012 IP