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
+39.5k Golang : UDP client server read write example
+7.8k Golang : How To Use Panic and Recover
+6.4k Golang : Humanize and Titleize functions
+17.6k Golang : Put UTF8 text on OpenCV video capture image frame
+8.4k Golang : Combine slices but preserve order example
+20.8k Golang : How to get time zone and load different time zone?
+35.6k Golang : How to split or chunking a file to smaller pieces?
+5.5k CodeIgniter/PHP : Remove empty lines above RSS or ATOM xml tag
+6.2k Golang : Spell checking with ispell example
+8.1k PHP : How to parse ElasticSearch JSON ?
+37.5k Golang : Read a text file and replace certain words
+4.3k Mac OSX : Get disk partitions' size, type and name