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
+6.8k Golang : Pat multiplexer routing example
+8.2k Golang : Implementing class(object-oriented programming style)
+7k Golang : Squaring elements in array
+19.1k Golang : Populate dropdown with html/template example
+7k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+8.9k Golang : Get SPF and DMARC from email headers to fight spam
+13.5k Golang : Query string with space symbol %20 in between
+14.4k Golang : How to check if your program is running in a terminal
+7.7k Golang : Reverse a string with unicode
+34.5k Golang : How to stream file to client(browser) or write to http.ResponseWriter?
+17.4k Golang : Clone with pointer and modify value
+8.2k Golang : Check if integer is power of four example