If I tick the checkbox everything is fine, it only errors with an unchecked checkbox on line

$merit = $_POST['merit'];

It's not recognising the 'merit' form value, sorry don't have the error message, if left unticked