Android Question Get "echo"ed message by php in B4A

Hi
I'm trying to connect to my remote server by httputils2 in B4A with a php file uploaded there. I "Poststring" username and password, the php script checks if there is a valid user and then returns a message by "echo" (php command) a "successful login". I want to use this message and check if B4A application got this message, it'll do something. How can I get that message?
I've already seen https://www.b4x.com/android/forum/threads/how-to-get-the-echo-string-of-php-after-job-success.21178/ but Job.Getstring returns whole html script ( in which there is no php echo message)
I also appreciate other suggestions to check usernames and passwords using b4a and php.
 
Last edited:

OliverA

Expert
Licensed User
Longtime User
Upvote 0
What is the content of the returned HTML? Are you sure you are accessing the correct site?

Hi OliverA
Yes I’m sure. The login php file has uploaded on public html folder and I addressed “myurl.ir/login.php”
The content is some HTML code like “<p> enter your name </p> “ which is used for designing and stuff. It’s odd that every php code ( which is between <? php and ?> ) won’t be returned in Job.getstring
 
Upvote 0
Hi OliverA
Yes I’m sure. The login php file has uploaded on public html folder and I addressed “myurl.ir/login.php”
The content is some HTML code like “<p> enter your name </p> “ which is used for designing and stuff. It’s odd that every php code ( which is between <? php and ?> ) won’t be returned in Job.getstring

To make you sure that everything seems fine to me this is php script
B4X:
<?php
require_once 'config.php';
if (isset($_POST['do-login'])) {
    $username = $_POST['username'];
    $passwords = $_POST['password'];
    $query = mysqli_query($db, "SELECT * FROM users WHERE  username='$username' AND password='$passwords'");

    if (mysqli_num_rows($query) > 0) {
        $message="success";
     echo utf8_encode($message);
      
    }
   else{ 
       $error="ERROR";
       echo utf8_encode($error);}
}
?>

config.php is a script which checks if the connection between server and database is established. It'll echo "connected" that fortunately Job.getstring returns!!!

B4X:
<?php
$db=mysqli_connect('my url','database name','database password','user');
if (!$db)
{
    echo 'Not Connected';
}
else{echo 'connected';}

?>
 
Upvote 0
Top