2
In the research I have done on checkbox I have seen several alternatives for inserting checkbox values, using methods with array and loops.
However I want to insert only 1, it is still necessary to use array and loops.
The following code is returning error, how to adapt as simply as possible.
<form method="post" action="trata_check.php">
<input id="" type="checkbox" name="um" value="um">Um
<input id="" type="submit" value="gogopls">
</form>
trata_check.php
<?php
include 'conect.php';
$um = $_POST['um'];
$sql =
"INSERT INTO part_1
(um)
VALUES
('$um')";
if ($con->query($sql) === TRUE) {
echo "realizado";
} else {
echo "Error: " . $sql . "<br>" . $con->error;
}
$con->close();
?>
I’m not finding a solution .
I need the brackets in the tmb input?
– MagicHat
I was wrong, there is no array in your code. How are you submiting the form?
– user28595
<input type"Submit" value="gogopls">
– MagicHat
is receiving the value 1, not the string...
– MagicHat
What a mistake that happens?
– user28595
No error but receives 1 as value....
– MagicHat
I don’t know how but now it has.... mygood Gratz @diegofm
– MagicHat