B4J Question [BANano]: [SOLVED] Using MySQL / MSSQL with PHP


Licensed User
Hi there

Update: April 8, 2019 Solution

[BANAno] MySQL CRUD with PHP - Part 1
[BANano] MySQL CRUD with PHP - Part 2

I have an issue that I need to address. I have a backend that I need to speak to from my BANano App, this could either be MySQL or either MSSQL (no decision as yet). I guess with PHP this could happen well, this will basically be for CRUD functionality.

What advise can you push my way on such? (if any)

Last edited:


Well-Known Member
Licensed User
Here is a very simple code to show how to communicate with the server via BANano Inline-PHP:

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.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!

End Sub


    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
        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)
End Sub
Greetings ... Peter