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:@"fdfs@jkjlf.cm"];
[request setPostValue:@"pwd" forKey:@"fdsfdsfdkskfjhds"];
[request setRequestMethod:@"POST"];
i got a null value with req.FormValue("userid")
what happend? and how to fix it?
Try this buddy.
hope it will work as it works for me
did you already test it with
req.PostFormValue
instead ofreq.FormValue
?