Get form post value in Go
Practically almost every web page out there will ask you to fill a form to progress further. Most of these forms will post data to the server for further processing. Go has the capability to capture the posted form data as well. In this tutorial, we will show a simple function to capture the posted form data with
r.FormValue("form_data")
function
In the client browser:
<form action="http://website/process_form_data" method="post">
<input type="text" name="form_data" id="form_data" >
</form>
At the Go server :
func process_form_data(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
form_data := r.FormValue("form_data")
}
}
For more information, please refer to
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+14.2k Golang : Get checkbox or extract multipart form data value example
+8.6k Golang : Load ASN1 encoded DSA public key PEM file example
+17.3k Golang : Get path name to current directory or folder
+14.6k Golang : Update database with GORM example
+5.2k Golang : Join lines with certain suffix symbol example
+13.5k Golang : Rename directory
+12.3k Golang : Set image canvas or background to transparent
+8.7k Golang : Bcrypting password
+13.9k Golang : Force download file example
+29.3k Golang : Download file example
+24.4k Golang : How to write CSV data to file
+32.8k Golang : How to stream file to client(browser) or write to http.ResponseWriter?