func login(rw http.ResponseWriter, req *http.Request) {
req.ParseForm()
if req.Method == "GET" {
fmt.Fprintf(rw, "Error Method")
} else {
name := strings.TrimSpace(req.FormValue("userid"))
fmt.Println("userid:", name)
fmt.Println("pwd:", req.FormValue("pwd"))
fmt.Fprintf(rw, "welcome back,%s", req.FormValue("userid"))
}
}
and i using ASIhttprequst send a from,like this.
[self setRequest:[ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://127.0.0.1:8080/login"]]];
[request setPostValue:@"userid" forKey:@"[email protected]"];
[request setPostValue:@"pwd" forKey:@"fdsfdsfdkskfjhds"];
[request setRequestMethod:@"POST"];
i got a null value with req.FormValue("userid")
what happend? and how to fix it?
did you already test it with req.PostFormValue
instead of req.FormValue
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With