Hi,
I am trying to create a checkbox form to pass a value of ‘-1’ to a field called ‘absence’ in a table called ‘notes’.
The form is as follows,
<form action="addnotes" method="post">
<div>
Absence: <input type="checkbox" name="absence" id="absence" value="-1">
</div>
<div>
<!-- <input type="hidden" name="id" value="unsure"> -->
<input type="submit" value="Add notes">
</div>
</form>
The index.php file,
if (isset($_GET['addnotes']))
{
include $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/db.inc.php';
try
{
$sql = 'INSERT INTO notes SET
absence = :absence';
$s = $pdo->prepare($sql);
$s->bindValue(':absence', $_POST['absence']);
$s->execute();
}
catch (PDOException $e)
{
$error = 'Error adding submitted absence.';
include 'error.html.php';
exit();
}
header('Location: .');
exit();
}
I think $_POST[‘absence’] should equal ‘-1’ when the checkbox is checked and the form submitted.
But I just get a 404 Error page.
Any help would be greatly appreciated.
Thanks,
Shane