Working on getting a form to send data to mysql when submitted, using API calls. I currently have the form submitted successfully and displaying a message on a blank page simply displaying "worked". I am using GO as my backend, and using bootstrap and HTML for the front end
The issue I am having is trying to get the page to redirect to a url instead of displaying that message. I have tried to implement something in the HTML form however it seems to be overridden by the function in my GO application
This is the current GO function which handles the process:
func insertv4Reservation(ctx echo.Context) error {
stmt, err := ipamDB.Prepare(ipamSQL.Insertv4HostsStatement)
if err != nil {
log.Fatal(err)
}
defer stmt.Close()
var identifier_value = ctx.FormValue("dhcp_identifier_value")
var identifier_type = 0 //value 0 corresponds to hw-address,
var dhcp_subnet_id = ctx.FormValue("dhcp4_subnet_id")
var ipv4_reservation = ctx.FormValue("octet1")
var hostname = ctx.FormValue("hostname")
var next_server = ctx.FormValue("dhcp4_next_server1")
//var dhcp4_ser_host = ctx.FormValue("dhcp4_server_hostname")
//var dhcp4_bf_name = ctx.FormValue("dhcp4_boot_file_name")
res, err := stmt.Exec(identifier_value, identifier_type, dhcp_subnet_id, ipv4_reservation, hostname, next_server)
if err != nil {
log.Fatal(err)
}
lastId, err := res.LastInsertId()
if err != nil {
log.Fatal(err)
}
rowCnt, err := res.RowsAffected()
if err != nil {
log.Fatal(err)
}
log.Printf("ID = %d, affected = %d
", lastId, rowCnt)
return ctx.String(http.StatusOK, "worked")
please bear in mind I am relatively new to GO, so please do comment any code given