prepare($sql); // Handle empty dates $client_id = empty($client_id) ? null : $client_id; $start_date = empty($start_date) ? null : $start_date; $end_date = empty($end_date) ? null : $end_date; $stmt->execute([$name, $description, $client_id, $status, $start_date, $end_date]); header("Location: projects.php?success=1"); exit(); } catch (PDOException $e) { header("Location: projects.php?error=" . urlencode($e->getMessage())); exit(); } } else { header("Location: projects.php?error=invalid_input"); exit(); } } ?>