[HELP] How would I make NUI send data to database

How would I send the text input from an NUI go to my database, I know you have to use a server event and all that, but that is where I am getting stuck.

Client side:(obviously not all of it)

RegisterNUICallback(“main”, function(data)
chat("Patient Name: ", {55,255,200})
chat(data.text, {0,255,0})
TriggerServerEvent(‘add’, data.text)
SetDisplay(false)
end)

Server Side:

RegisterServerEvent(“add”)
AddEventHandler(“add”, function(data)
MySQL.Async.fetchAll(“INSERT INTO medical (name) VALUES(@name)”,
{["@name"] = data.text})
TriggerClientEvent(“done”)
end)

It could be something very simple I am not to bright though XD.

1 Like