go - Form Always Empty -
i've been building go todo list , i'm trying add ability add new items, every time access form value, comes out empty. here's handler built:
func addhandler(w http.responsewriter, r *http.request) { err := r.parseform() if err != nil { fmt.print(err) } cook, _ := r.cookie("userid") id := cook.value r.parseform() text := r.formvalue("todo") addtodo(text,id) //inserts database http.redirect(w,r,"/todo",http.statusfound) }
and here's html
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>title</title> </head> <body> <table> {{range .}} <tr><td>{{printf "%s" .text}}</td><td><a href="/delete/{{.id}}">delete</a></td></tr> {{end}} </table> <form action="/add" method="post"><input type="text" name="todo"><button type="submit">add</button></form> </body> </html>
Comments
Post a Comment