Android Question Value does not appear in the PHP page

Isac

Active Member
Licensed User
Longtime User
In the log files I read that the value is passed, but the website does not appear

B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: False
#End Region

Sub Process_Globals

End Sub

Sub Globals

'Private EditText1 As EditText   
Private Button1 As Button
Dim job2 As HttpJob

   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("test")

End Sub
Sub Activity_Resume


End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
   
'    Dim name As String = EditText1.Text
'    If name = "" Then
'        Msgbox("Please enter Name", "Error")
'        Return   
'    End If


'Send a POST request

   job2.Initialize("Job2", Me)
   job2.PostString("http://www.mysite.com/test.php", "p1=45&p2=552")
  
End Sub   




Sub JobDone (Job As HttpJob)
   Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
   If Job.Success = True Then
            'print the result to the logs
            Log(Job.GetString)
   Else
      Log("Error: " & Job.ErrorMessage)
      ToastMessageShow("Error: " & Job.ErrorMessage, True)
   End If
   Job.Release
End Sub

-------------------------------


Logs
JobName = Job2, Success = true
I've received 45 and 552

--------------------------------

Page PHP

PHP:
<?

$p1 = $_POST["p1"];
$p2 = $_POST["p2"];

print ("I've received $p1 and $p2");

?>

---------------------------------
I only see this page in PHP:

I've received and
 

DonManfred

Expert
Licensed User
Longtime User
$poststring is using a format which must be acceptd by the php (which is not)
Do job.multipartpost-request or rewrite your php to accept raw-posts
 
Upvote 0

Isac

Active Member
Licensed User
Longtime User
I tested with html and it works great.

HTML:
<html>
<head>
<body>
<form action="test.php" method="post">
First name:<br>
<input type="text" name="p1"/><br>
Last name:<br>
<input type="text" name="p2"/><br>
</body>
<br>
<input type= "submit" value="send"/>
</form>
</html>

-----------------------------------


Currently it is in these conditions

php

PHP:
<?

$p1 = $_REQUEST["p1"];
$p2 = $_REQUEST["p2"];

print ("I've received $p1 and $p2");

?>

----------------------------------------------------


b4A

B4X:
job2.Initialize("Job2", Me)
job2.Download2("http://mysite.org/test.php", _
Array As String ("p1","45", "p2","552"))


-------------------------------------------------------


LOG B4A
I've received 45 and 552
 
Upvote 0

Isac

Active Member
Licensed User
Longtime User
but it does not work with

B4X:
job2.Initialize("Job2", Me)
job2.Download2("http://mysite.org/test.php", _
Array As String ("p1","45", "p2","552")
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
job2.Initialize("Job2", Me)
job2.Download2(
"http://mysite.org/test.php", _
Array As String ("p1","45", "p2","552")
Job.Download(2) is a GET-Request!

Change your php to use GET-Values then it will work with Download2

PHP:
<?

$p1 = $_GET["p1"];
$p2 = $_GET["p2"];

print ("I've received $p1 and $p2");

?>

As written in post #8 you also can use $_REQUEST. REQUEST will hold both; GET and POST Values.
 
Last edited:
Upvote 0

Isac

Active Member
Licensed User
Longtime User
Hi DonManfred,
php is right, I am using $ _REQUEST
The log indicates that the value is passed: I've received 45 and 552
I do not understand why with html code works.
I'm doing some tests on altervista, but I do not think that's the problem
I tried everything
A mistery :)
 
Upvote 0
Top