Jump to content

checkbox data not going into database


disturbed1

Recommended Posts

Hello

 

I have one checkbox on my form and it is supposed to put a 1 in the database if it is checked and a 0 if it isn't checked. My problem is that whether the box is checked or unchecked only 0's are placed into the database. How can I fix this problem? The type that I am using for the checkbox is bool/tiny int.

 

<?php

$DRCVD = $_POST['DRCVD'];

$OCONT = $_POST['OCONT'];

$CONTENTS = $_POST['CONTENTS'];

$DEADLINE = $_POST['DEADLINE'];

$GIVENTO = $_POST['GIVENTO'];

$STATUS = $_POST['STATUS'];

$COMPLETED = $_POST['COMPLETED'];

$OUTCOME = $_POST['OUTCOME'];

$NOTES = $_POST['NOTES'];

 

 

$con = mysql_connect("hahfhfh", "fggh", "agagg");

mysql_select_db("ahfhfshfsh", $con);

 

$query = "INSERT INTO cases (DRCVD, OCONT, CONTENTS, DEADLINE, GIVENTO, STATUS, COMPLETED, OUTCOME, NOTES)

VALUES ( '$DRCVD', '$OCONT', '$CONTENTS', '$DEADLINE', '$GIVENTO', '$STATUS', '$OUTCOME', '$NOTES',";

 

if (isset($COMPLETED))

$query = $query . "1 )";

else

$query = $query . "0 )";

 

$result = mysql_query($query);

 

 

 

?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/101909-checkbox-data-not-going-into-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.