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
+7.6k Golang : How to stop user from directly running an executable file?
+6.1k PHP : How to check if an array is empty ?
+48k Golang : Convert int to byte array([]byte)
+7k Mac/Linux/Windows : Get CPU information from command line
+6.2k Golang : Missing Subversion command
+17.5k Golang : Get future or past hours, minutes or seconds
+7k Golang : Join lines with certain suffix symbol example
+3.5k Golang : Fix go-cron set time not working issue
+10k Golang : Sort and reverse sort a slice of integers
+6.5k Golang : Break string into a slice of characters example
+4.7k Javascript : Detect when console is activated and do something about it
+21k Golang : Convert PNG transparent background image to JPG or JPEG image