Handle the registration form
Well, just log it for now.
This commit is contained in:
parent
214588ba83
commit
ebb55556d2
3 changed files with 23 additions and 4 deletions
18
endpoint.go
18
endpoint.go
|
|
@ -1,6 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
func getFavicon(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -21,3 +22,20 @@ func getSignup(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
||||
func postSignup(w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseForm(); err != nil {
|
||||
log.Printf("Error parsing form: %v", err)
|
||||
http.Error(w, "Failed to process form", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
email := r.FormValue("email")
|
||||
name := r.FormValue("name")
|
||||
terms := r.FormValue("terms")
|
||||
|
||||
log.Printf("Signup - Email: %s, Name: %s, Terms: %s", email, name, terms)
|
||||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte("Form received"))
|
||||
}
|
||||
|
|
|
|||
1
main.go
1
main.go
|
|
@ -57,6 +57,7 @@ func main() {
|
|||
|
||||
r.Get("/", getRoot)
|
||||
r.Get("/signup", getSignup)
|
||||
r.Post("/signup", postSignup)
|
||||
r.Get("/favicon.ico", getFavicon)
|
||||
|
||||
localFS := http.Dir("./static")
|
||||
|
|
|
|||
|
|
@ -54,19 +54,19 @@
|
|||
<p class="text-muted">Join us today to get started</p>
|
||||
</div>
|
||||
|
||||
<form>
|
||||
<form method="POST" action="/signup">
|
||||
<div class="mb-3">
|
||||
<label for="name" class="form-label">Full Name</label>
|
||||
<input type="text" class="form-control" id="name" required>
|
||||
<input type="text" class="form-control" name="name" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="email" class="form-label">Email Address</label>
|
||||
<input type="email" class="form-control" id="email" required>
|
||||
<input type="email" class="form-control" name="email" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" class="form-check-input" id="terms" required>
|
||||
<input type="checkbox" class="form-check-input" name="terms" required>
|
||||
<label class="form-check-label" for="terms">I agree to the <a href="#">Terms of Service</a> and <a href="#">Privacy Policy</a></label>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue