If a checkbox isn't checked (see "checked"-Attribute of input type checkbox), nothing is sent to the server.
$_POST['B1'] gets the value of the element with NAME 'B1' if it is sent to the server.
So
$b1 = (isset($_POST['B1'])) ? 1 : 0;
should do the trick. $b1 will be 0 if the checkbox is unchecked and 1 if it is checked.
Option 1
The SQL looks like you are trying to put something like 01100 into the database field 'B2'.
Usually you would store the result of every checkbox in a single database column. But if you really want to concat them, your code should look like this:
$stmt = $conn->prepare('INSERT INTO Results ($UserID, B1, B2 ) VALUES (:UserID, :B1, :B2, :B3, :B4, :B5, :B6);');
$stmt->execute(array(
':UserID' =>$_POST['UserID'],
':B1' =>$_POST['B1'],
':B2' =>(isset($_POST['B2'])) ? 1 : 0 + (isset($_POST['B3'])) ? 1 : 0 + (isset($_POST['B4'])) ? 1 : 0 + (isset($_POST['B5'])) ? 1 : 0 + (isset($_POST['B6'])) ? 1 : 0
));
Option 2
If you have one database field for every B1...B6-value then you've forgotten to take these columns into your SQL-INSERT-Statement:
INSERT INTO Results ($UserID, B1, B2, B3, B4, B5, B6) [...]
And your stmt execute is wrong and should be:
$stmt->execute(array(
':UserID' =>$_POST['UserID'],
':B1' => isset($_POST['B1']) ? 1 : 0,
':B2' => isset($_POST['B2']) ? 1 : 0,
':B3' => isset($_POST['B3']) ? 1 : 0,
':B4' => isset($_POST['B4']) ? 1 : 0,
':B5' => isset($_POST['B5']) ? 1 : 0,
':B6' => isset($_POST['B6']) ? 1 : 0
));
1, why are you setting the values the same as the names? And note that unchecked checkboxes are not sent to the server.