Other to pass variables to PHP

Stefano Grandi

Member
Licensed User
Hi.
In B4A this code runs well but in B4I doesn't run.
How can I pass variables to PHP?
thank you for your cooperation


B4X:
Dim Indirizzo_Server="79.8.xx.xxx" As String 
    Dim Nome ="STEFANO"  As String
    Dim PW ="000000000" As String
        
    WebView1.LoadUrl("http://" & Indirizzo_Server &  "/prova.php?nome='" & Nome & "' & passwordonline='" & PW & "'")


' in PHP:
<?php 

$nome=$_GET['nome'];
$passwordonline=$_GET['passwordonline'];
echo("Nome: " & $nome & "<br>");
echo("passwordonline: " & $passwordonline);
?>
 

Stefano Grandi

Member
Licensed User
Hi Erel

In all examples I read variables but I have to pass variables to PHP. The PHP have to work (a lot) and the result must be in WEBVIEW.
Can You post an example for this case? (in B4I because in B4A it runs well)

Many Thanks

Stefano Grandi
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
I dont know any differences between b4a and b4i about httputils or webview. they must be the same
 
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
For me is working fine with webservice construct with PHP, like this:

Server Side:
B4X:
<?php

  $id      = $_GET['id'];
  $iduser  = $_GET['iduser'];
  $version = $_GET['version'];
  $uuid    = $_GET['uuid'];

?>

and App Side
B4X:
Dim jobGet As HttpJob
jobGet.Initialize("jobname", me)
jobGet.Download("http://myserver/page.php?id=111&iduser=333&version=1.1.1&uuid=4444444444444")

Just be careful with special characters, for this use like this:
B4X:
Dim SU As StringUtils
 Dim strSearch As String = "id=111&iduser=333&version=1.1.1&uuid=4444444444444&Search=" &SU.EncodeUrl("nonon  nonon ononononon nonon", "UTF8")

Dim jobGet As HttpJob
jobGet.Initialize("jobname", me)
jobGet.Download("http://myserver/page.php?" & strSearch)
 
Upvote 0

Stefano Grandi

Member
Licensed User
Thanks for Your answer

Now have this problem
I'm not expert in B4X.Perhaps I ask elementary questions.
Now I have this problem:
How can connect jobget.download (variable of HttpJob) to webview?

Thanks

Stefano Grandi
 
Upvote 0

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
I don't understand your question... You mean the result of this download?

if yes, when you send the download command you will receive in "jobDone" event, like this:

B4X:
Sub JobDone (Job As HttpJob)
  
       If Job.Success = True Then
  
        Select Job.JobName
     
            Case "jobname"
                    Dim strResult as string = Job.GetString

        End Select
 
  
    End If
  
    Job.Release
  
End Sub

and you can use "strResult" in your webview
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Word of caution: I never send variables in the GET method. Thats how they get logged/sniffed easier. use the POST method instead.
 
Upvote 0
Top