I've been trying to let PHP script receive data POSTed by BANano unsuccessfully. Could someone kindly tell me what went wrong, please? TIA
The following php script snippet works for B4A.
On BANano side, I use the code posted by @alwaysbusy here:
Complete php script file:
The following php script snippet works for B4A.
Same script used for B4A to POST data to PHP:
$post = file_get_contents('php://input');
var_dump($post); //output: empty
$arr = json_decode($post, true); //output: $arr is null
$order_id= intval($arr["order_id"]);
On BANano side, I use the code posted by @alwaysbusy here:
[Banano] Converting httpjob code from B4A
I just started learning Banano and I'm wondering how to convert the following piece of B4A code to Banano PWA. It would be great if someone could kindly give me a hint or two. TIA Dim map1 As Map = CreateMap("orderid": "12345678", "customer_id": "1234") Dim JSON As...
www.b4x.com
Complete php script file:
test1.php file used by BANano:
<?php
//1. connnect to mysql:
//////database/////////////////
$servername = "localhost";
$dbname = "xdurxttx_test";
$username ="xdurxttx_test";
$password ="xxxxxxxx";
/////////////////////////////
// Create connegtion
$conn = new mysqli($servername, $username, $password, $dbname);
//$conn->query("SET CHARACTER SET utf8");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//2. get post data
//read map data from POST method:
/***/
$post = file_get_contents('php://input');
var_dump($post);
$arr = json_decode($post, true);
$order_id= intval($arr["order_id"]);
//3. retrieve data from mysql:
try{
$sql="SELECT * from orderitems
WHERE order_id=$order_id ";
echo $sql;
$result = $conn->query($sql);
if ($result->num_rows > 0){
$rows = array();
while($r = $result->fetch_assoc())
{
$rows[] = $r;
}
print json_encode($rows);
}
else{
echo '[{"result":0,"message":"no matching record"}]';
}
}//catch exception
catch(Exception $e) {
echo '[{"result":"-100","message":"',$action, ", ", $e->getMessage, '"}]';
}
$conn->close();
?>