Sub Process_Globals
Dim BANano As BANano 'ignore
End Sub
Sub AppStart (Form1 As Form, Args() As String)
BANano.Initialize("InlinePhpTest", "InlinePhpTest", 1)
BANano.UseServiceWorker = False
BANano.HTML_NAME = "index.html"
BANano.Header.Title = "InlinePhpTest"
BANano.Header.AddCSSFile("https://cdnjs.cloudflare.com/ajax/libs/mini.css/3.0.1/mini-default.min.css")
BANano.PHP_NAME = "GetData.php"
BANano.PHPHost = "http://localhost/BANano/InlinePhpTest/"
BANano.PHPAddHeader("Access-Control-Allow-Origin: *")
BANano.Build("C:\inetpub\wwwroot\BANano\") ' Customize to your needs!
ExitApplication
End Sub
#If PHP
function Login($Username, $Password) {
if ($Username=="John" && $Password=="Doe") {
echo "OK";
} else {
echo "KO";
}
}
#End If
Sub InlinePhpTest_Ready()
BuildInput("txtUsername", "text", "Username:", "John")
BuildInput("txtPassword", "password", "Password:", "Doe")
BuildButton("btnLogin", "Login")
BANano.GetElement("body").Append("<br />")
End Sub
public Sub btnLogin_Click(event As BANanoEvent)
If BANano.CheckInternetConnectionWait Then
Dim Username As String = BANano.GetElement("#txtusername").GetValue
Dim Password As String = BANano.GetElement("#txtpassword").GetValue
Dim Result As String = BANano.CallInlinePHPWait("Login", CreateMap("Username":Username, "Password":Password))
Select Result
Case "OK"
AddOutput("Login: OK :-)")
Case Else
AddOutput("Login failed!")
End Select
Else
AddOutput("You are not connected to the internet!")
End If
End Sub
Sub BuildInput(ID As String, InputType As String, LabelText As String, Value As String)
ID = ID.ToLowerCase
BANano.GetElement("body").Append($"<label for="${ID}">${LabelText}</label>"$)
BANano.GetElement("body").Append($"<input type="${InputType}" id="${ID}" value="${Value}">"$)
End Sub
Sub BuildButton(ID As String, Text As String)
ID = ID.ToLowerCase
Dim Button As BANanoElement = BANano.GetElement("body").Append($"<button id="${ID}">${Text}</button>"$).Get($"#${ID}"$)
Button.On("click", Me, ID & "_click")
End Sub
Sub AddOutput(Message As String)
BANano.GetElement("body").Append($"<p>${Message}</p>"$)
End Sub