0

How to send check box data in database using xampp server?

I made a form and give it many inputs of type text,email,radio, checkbox. The language used is php and html. how to send the data of check box in the table of database.

5th Nov 2022, 5:29 AM
parajal12
parajal12 - avatar
4 Respostas
+ 6
When the user submits the form, the page in the form action property is invoked. This page (something.php) would have to process the incoming data that is stored in the $_GET or $_POST superglobals. And in the PHP script itself you have to connect to the database and execute the appropriate SQL instructions (INSERT, UPDATE, DELETE...) https://www.w3schools.com/php/php_forms.asp https://www.w3schools.com/php/php_mysql_insert.asp
5th Nov 2022, 5:49 AM
Tibor Santa
Tibor Santa - avatar
+ 3
I cannot validate and try your code but it seems to have obvious errors, with wrong uppercase characters in keywords, and you put a semicolon after foreach?? But as far as the concept goes, yes this is a good start and it should work after you fix the syntax errors, and add the correct details to the connection parameters and the SQL query. The table would need to exist already (so create it manually in SQL admin, or by a similar script). And check if autocommit is enabled in your database, otherwise you may need to issue a commit instruction as well.
6th Nov 2022, 6:03 AM
Tibor Santa
Tibor Santa - avatar
+ 1
For checkbox if I write code on something.php file $con=('server','username','password','db_name'); If(isset($_POST['submit'])) { $txtcb=$_POST('txtcb'); Foreach($txtcb as $key); $query="INSERT INTO TABLE_NAME(col_name) Values('$key'); Will it insert data of checkbox in the database table ?Tibor Santa
6th Nov 2022, 5:22 AM
parajal12
parajal12 - avatar
0
Ok thank you Tibor Santa
6th Nov 2022, 7:05 AM
parajal12
parajal12 - avatar