title: PHP: Submit checkbox to database
body: <p>I am having trouble submitted checkbox values and details to my database.</p>
  
  <p>This is my HTML:</p>
  
  <pre><code>&lt;form method="get" action="check.php"&gt;
              &lt;input type="checkbox" name="checkAccount"/&gt;
              &lt;input type="hidden" name="table_name" value="masterChart" /&gt;
              &lt;input type="hidden" name="column_name" value="account" /&gt;
              &lt;p&gt;&lt;a href='check.php'&gt;&lt;input type="submit" class="btn btn-primary" value="Submit" /&gt;&lt;/a&gt;&lt;/p&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>This is the check.php:</p>
  
  <pre><code>$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');
  </code></pre>
  
  <p>As you can see above, I used variables to get other details for that checkbox to insert into the table as well. </p>
  
  <p>After I press submit if the checkbox is checked, this is what's seen in the url:</p>
  
  <pre><code>http://localhost/admin/check.php?checkAccount=on&amp;table_name=masterChart&amp;column_name=account
  </code></pre>
  
  <p>Any suggestions or help will be appreciated!</p>