Android Question PHP code showing in Html Input form after Compile

Discussion in 'Android Questions' started by no12u, Jul 24, 2015.

  1. no12u

    no12u New Member Licensed User

    I have a php page that has an input form. This input uses php code to get a session variable from another page to pre-populate the input form. It works as it should in my localhost/xampp environment but after compiling these pages in B4A the input form that is supposed to be populated with the text of the variable, now shows up as the php code ie, <?php echo $variable ?>. I think it is coming from the quoted (") value of the form and showing as quoted text. I have tried everything I can think of to remedy this on the php side but nothing works. I have to populate the form with php. Is there something on the B4A side that I can do? Everything else works in the compiled apk but that.
     
  2. DonManfred

    DonManfred Expert Licensed User

    do you try to call php code on your device? Or what do you mean with compiling?

    What is the url you are calling?
     
  3. no12u

    no12u New Member Licensed User

    Thank you for your time...
    I am calling file:///android_asset/cname_input.php and using a webview. All pages (files) are php with javascript and html. I ran the compiler on those pages. When i install the apk on my phone everthing works but the input. The input form should show a pre-populated name drawn from a sqlite db using php code but the input form is populated with the php code instead of the name. Below is the b4a

    Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim WebView1 As WebView
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("choreday")
    WebView1.Initialize("WebView1")
    Activity.AddView(WebView1, 0, 0, 100%x, 100%y)

    WebView1.LoadUrl("file:///android_asset/cname_input.php")
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub
    Sub WebView1_PageFinished (Url As String)
    ' the WebView has finished loading the web page, the javascript file has been loaded and it's function are ready to be called
    Dim Javascript As String
    Javascript="javascript:setHTML('div2', 'The web page has now loaded...')"
    WebView1.LoadUrl(Javascript)
    End Sub
     
  4. NJDude

    NJDude Expert Licensed User

    Android's webview it doesn't executes PHP code, you need a PHP server for that.
     
    lemonisdead likes this.
  5. DonManfred

    DonManfred Expert Licensed User

    It will not work! To execute php you need to run a php-capable webserver. Android dont have a webserver onboard. You need to place the php-files on your own webserver and call the url on your webserver in your webview
     
    lemonisdead likes this.
  6. no12u

    no12u New Member Licensed User

    Ok, so if I could get the values to and from sqlite with javascript then it should work, as all of the other code for the the app is javascript and html, is that right.. if so any ideas?
     
Loading...