M mohammad javad Member Jul 4, 2020 #1 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: Jul 4, 2020
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.
OliverA Expert Licensed User Longtime User Jul 4, 2020 #2 mohammad javad said: in which there is no php echo message Click to expand... What is the content of the returned HTML? Are you sure you are accessing the correct site? Upvote 0
mohammad javad said: in which there is no php echo message Click to expand... What is the content of the returned HTML? Are you sure you are accessing the correct site?
M mohammad javad Member Jul 4, 2020 #3 OliverA said: What is the content of the returned HTML? Are you sure you are accessing the correct site? Click to expand... 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
OliverA said: What is the content of the returned HTML? Are you sure you are accessing the correct site? Click to expand... 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
M mohammad javad Member Jul 4, 2020 #4 mohammad javad said: 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 Click to expand... To make you sure that everything seems fine to me this is php script Code: <?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!!! Code: <?php $db=mysqli_connect('my url','database name','database password','user'); if (!$db) { echo 'Not Connected'; } else{echo 'connected';} ?> Upvote 0
mohammad javad said: 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 Click to expand... To make you sure that everything seems fine to me this is php script Code: <?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!!! Code: <?php $db=mysqli_connect('my url','database name','database password','user'); if (!$db) { echo 'Not Connected'; } else{echo 'connected';} ?>
toby Well-Known Member Licensed User Longtime User Jul 4, 2020 #5 try the following https://www.b4x.com/android/forum/threads/connect-android-to-mysql-database-tutorial.8339/ https://www.b4x.com/android/forum/t...-local-php-mysql-server-xampp-with-b4a.48635/ Upvote 0
try the following https://www.b4x.com/android/forum/threads/connect-android-to-mysql-database-tutorial.8339/ https://www.b4x.com/android/forum/t...-local-php-mysql-server-xampp-with-b4a.48635/