Sub loginw(e As BANanoEvent)
Dim strUser As String = banano.GetElement("#txtusername").GetValue
Dim strPwd As String = banano.GetElement("#txtpassword").GetValue
'build php query
Dim straction As String = "validateuser"
Dim dbAction As Map
dbAction.Initialize
dbAction.Put("action=", straction)
dbAction.Put("username=", strUser)
dbAction.Put("userpassword=", strPwd)
'build the php
Dim m As Map = BuildPHP(dbAction,"users.php",straction)
Dim headers As Map = m.Get("headers")
Dim sCommand As String = m.Get("command")
Dim result As String = banano.CallAjaxWait(sCommand, "GET", "json","",False, headers)
Log(result)
Log("Done")
End Sub
'build the php to execute
Sub BuildPHP(pQuery As Map, phpFile As String, phpTag As String) As Map
Dim json As String
Dim sCommand As String = ""
json = Map2QueryString(pQuery)
If Len(json) = 0 Then
sCommand = $"${PhpPath}${phpFile}"$
Else
sCommand = $"${PhpPath}${phpFile}?${json}"$
End If
'create the headers
Dim headers As Map
headers.Initialize
headers.put("Content-Type", "application/json")
headers.Put("Access-Control-Allow-Origin", "*")
'create map things
Dim m As Map = CreateMap("headers":headers,"command":sCommand)
Return m
End Sub