I'm having a little trouble with a form i'm saving in a database.
Basically, I have a form with checkboxes, every checkbox is connected to a column inside a mySQL database, when checked, and submitbutton is pressed, it saves the value from that checkbox, if not, it will stay empty.
Everyting works fine and saves to the database, but the boxes that are unchecked give the following notice:
Undefined index: WBR in /var/www/vhosts/leadserver.be/httpdocs/LPRamen/insert.php on line 35
Keep in mind, These are just snippets of my code, the total is way to long to post
I know that there are several topics on this already but i've done the research and none of the solutions seem to work. If somebody could take a look at this and find out what's wrong, i would be most greatful.
I've also tried to set a standard value in the database if a field stays empty, that didn't work.
I've set the indexes on the database columns correctly as well, but i still get the same notice.
Solution 2
Checkbox data will only be sent via $_POST if it's checked, otherwise the VBR key won't exist in your array.
You should check for it using the php function, isset().
An undefined index message means you are trying to access an array index that doesn't exist.
When using checkboxes, you don't get a value set if it's not checked.
So, when you process the form, check to see if the checkbox has been sent in.