Jump to content

undefined index on check box

Recommended Posts

I'm facing trouble on check box when register form is submitted without check the check button, but when the button is checked the error disappear .

can you give me idea why and how to solve this issue.

I saw many sites with  such kind of button on registration form please any one who can solve this.

Share this post

Link to post
Share on other sites

Only select check boxes (and radio buttons) are sent in the form data so you need you check if they are present using isset().


   for ($i=1; $i<=5; $i++) {
       if (isset($_GET['mycb'][$i])) {
           echo "Check box $i selected<br>" ;
       Check box 1 : <input type="checkbox" name="mycb[1]" value="1"><br>
       Check box 2 : <input type="checkbox" name="mycb[2]" value="2"><br>
       Check box 3 : <input type="checkbox" name="mycb[3]" value="3"><br>
       Check box 4 : <input type="checkbox" name="mycb[4]" value="4"><br>
       Check box 5 : <input type="checkbox" name="mycb[5]" value="5"><br><br>
       <input type="submit" name="btnSub" value="Submit">


  • Like 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.