Send value "0" or "1" from the checkbox to the database [duplicate]

0

I have the table "Cd_Comments" in the mysql database, with the column "comment_id" "user_id" "text" and "anonymously" I want to make a system for a site, where the user will comment, and if you have checked the checkbox "send anonymously?" it sends the value "1" to the "anonymous" column of the "coment" table and if nothing is marked it sends the value "0"

I'm using the following input for the checkbox

                <input type="hidden" name="anony" id="caixa-disabled" value="0" <?php echo ($cd['comentarios']['anononimo'] == 0) ? 'checked': '';?>>
                 <input type="checkbox" name="anony" id="caixa-enabled" value="1" <?php echo ($cd['comentarios']['anononimo'] == 1) ? 'checked': '';?>>

But marking or not marking, no value is sent to the database.

I do not use pure html, so I can do the logical and visual part all together, since it is a simple form, in a site that only has one page. Should I use echo? Post? It is necessary to do something in jquery to make this work or only PHP can solve the problem.

Sorry, I study programming a very short time (less than 1 month to be more accurate) and I'm lost

    
asked by anonymous 28.09.2018 / 17:31

0 answers