Jump to content

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.

Link to comment
https://forums.phpfreaks.com/topic/309662-undefined-index-on-check-box/
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().

Example

<?php
   for ($i=1; $i<=5; $i++) {
       if (isset($_GET['mycb'][$i])) {
           echo "Check box $i selected<br>" ;
       }
   }
?>
<html>
<head>
<title>Example</title>
</head>
<body>
<hr>
   <form>
       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">
       
   </form>
</body>
</html>

 

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.