I am having trouble submitted checkbox values and details to my database.
This is my HTML:
<form method="get" action="check.php">
<input type="checkbox" name="checkAccount"/>
<input type="hidden" name="table_name" value="masterChart" />
<input type="hidden" name="column_name" value="account" />
<p><a href='check.php'><input type="submit" class="btn btn-primary" value="Submit" /></a></p>
</form>
This is the check.php:
$table = $_GET['table_name'];
$column = $_GET['account'];
$dbc = mysqli_connect('localhost', 'root', 'root', 'database') or die('Connection error!');
if ($value = 1) {
$checkbox = "INSERT INTO login_table_display(`user`, `table`, `column`, `value`) VALUES(`:user`, '$table', '$column', `$value`)";
mysqli_query($dbc, $checkbox) or die('Database error, check!');
}
header('location:index.php');
As you can see above, I used variables to get other details for that checkbox to insert into the table as well.
After I press submit if the checkbox is checked, this is what's seen in the url:
http://localhost/admin/check.php?checkAccount=on&table_name=masterChart&column_name=account
Any suggestions or help will be appreciated!