I have 3 text fields and a hidden field. The text field accepts a date. If the date entered is later than today for any text field, it should display an error message. This only works properly if I enter a later date in the first text field. If I do it in the second or third, it continues to the redirect which obviously shouldn't happen.
$count = count($_POST['complete_date']);
for($i = 0; $i < $count; ++$i) {
if($_POST['complete_date'][$i] > date('Y-m-d')) {
echo error_message("Date can't be in the future");
break;
} else {
$stmt = $link->prepare("UPDATE `units` SET `complete_date` = ? WHERE `units` = ?");
$stmt->bind_param("si", $_POST['complete_date'][$i], $_POST['units'][$i]);
$stmt->execute();
$stmt->close();
header("location: dashboard.php");
exit();
}
}