package handlers import ( "log" "net/http" "synlotto-website/models" ) func Home(w http.ResponseWriter, r *http.Request) { log.Println("✅ Home hit") err := Tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{ "Page": "index", "Data": Draws, }) if err != nil { log.Println("❌ Template error:", err) http.Error(w, "Error rendering homepage", http.StatusInternalServerError) } } func NewDraw(w http.ResponseWriter, r *http.Request) { log.Println("➡️ New draw form opened") err := Tmpl.ExecuteTemplate(w, "layout", map[string]interface{}{ "Page": "new_draw", "Data": nil, }) if err != nil { log.Println("❌ Template error:", err) http.Error(w, "Error rendering form", http.StatusInternalServerError) } } func Submit(w http.ResponseWriter, r *http.Request) { log.Println("📝 Form submission received") r.ParseForm() draw := models.Draw{ Date: r.FormValue("date"), Machine: r.FormValue("machine"), Ballset: r.FormValue("ballset"), Ball1: r.FormValue("ball1"), Ball2: r.FormValue("ball2"), Ball3: r.FormValue("ball3"), Ball4: r.FormValue("ball4"), Ball5: r.FormValue("ball5"), Thunderball: r.FormValue("thunderball"), } Draws = append(Draws, draw) log.Printf("📅 %s | 🛠 %s | 🎱 %s | 🔢 %s,%s,%s,%s,%s | ⚡ %s\n", draw.Date, draw.Machine, draw.Ballset, draw.Ball1, draw.Ball2, draw.Ball3, draw.Ball4, draw.Ball5, draw.Thunderball) http.Redirect(w, r, "/", http.StatusSeeOther) }