;
                    const today = new Date();
                    const year = today.getFullYear();
                    const month = String(today.getMonth() + 1).padStart(2, '0');
                    const day = String(today.getDate()).padStart(2, '0');
                    document.getElementById('date').value = `${year}-${month}-${day}`;
                } else {
                    const error = await response.json();
                    messageDiv.textContent = `Error: ${error.error || 'Failed to add e