Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 into database
- http.Redirect(w,r,"/todo",http.StatusFound)
- }
- <!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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement