I give up!
How do you make this work???
I am trying to send post data to my web page like this:
And trying to retrieve a JSON object in return like this:
The 'JsonTextDecodeWithDictionaries' is not working with the data that my PHP code is sending to my app. My notifier popup is displaying 'not found' after the "\n##############\n". So that means local variable 'member' is empty and .JsonTextDecodeWithDictionaries is failing to decode the PHP generated JSON string. Why dammit?
Testing my web page in a web browser:
Page Contents:
I get the same data in a Notifier popup in my app so my web page is sending the app the JSON data as expected.
{"id":"1","trade":52,
"business_name":"Greg's Native Landscapes",
"first_name":"Greg"
,"surname":"Boyles",
"abn":"51 824 753 556",
"structure":"Sole trader",
"license":"Electrical license\r\nClass A\r\nNumber: 8743895324"
"description":"Ecological weed control\r\nLow maintenance\r\nDrought tolerant\r\nIrrigation systems\r\nSmall retaining walls\r\nSmall tree removal\r\nGeneral pruning\r\nBush tucker gardens\r\nSmall ornamental billabongs\r\nNative lawns",
"minimum_charge":"0000000120"
,"minimum_budget":"0000005000",
"maximum_size":"Up to 50",
"maximum_distance":"0000000100",
"unit":"Unit 3, building 6(Cooper)",
"street":"56 Derby Drive",
"suburb":"EPPING",
"state":"VIC",
"postcode":"3076",
"phone":"94013696",
"mobile":"0455328886",
"email":"gregplants@bigpond.com",
"expiry_date":"2024-02-08",
"username":"gregaryb",
"password":"{\"ct\":\"9PuKHhy9VLrfbNt+4XMBTQ==\",\"iv\":\"25666ca790a3be3cd825b0f4d3927ecb\",\"s\":\"c4165aa358be74dd\"} ","logo_filename":"Logo.jpg",
"profile_filename":"Me.jpg",
"additional_trades":["21","24","29","31","30","52","54","35"]}
Page source code:
<?php
require_once "CryptoJSAES.php";
require_once "common.php";
if (isset($_GET["button"]))
{
$_POST = $_GET;
}
if (isset($_POST["button"]))
{
if ($_POST["button"] == "LOGIN")
{
$strQuery = "SELECT * FROM members WHERE username='" . $_POST["username"] . "' OR email='" . $_POST["username"] . "' AND password='" . CryptoJsAes::encrypt($_POST["password"], $g_strKey) . "'";
$result = DoQuery($g_dbFindATradie, $strQuery);
if ($result->num_rows == 1)
{
$row = $result->fetch_assoc();
$member = (object)[];
$member->id = $row["id"];
$member->trade = (int)$row["trade_id"];
$member->business_name = $row["business_name"];
$member->first_name = $row["first_name"];
$member->surname = $row["surname"];
$member->abn = $row["abn"];
$member->structure = $row["structure"];
$member->license = $row["license"];
$member->description = $row["description"];
$member->minimum_charge = $row["minimum_charge"];
$member->minimum_budget = $row["minimum_budget"];
$member->maximum_size = $row["maximum_size"];
$member->maximum_distance = $row["maximum_distance"];
$member->unit = $row["unit"];
$member->street = $row["street"];
$member->suburb = $row["suburb"];
$member->state = $row["state"];
$member->postcode = $row["postcode"];
$member->phone = $row["phone"];
$member->mobile = $row["mobile"];
$member->email = $row["email"];
$member->expiry_date = $row["expiry_date"];
$member->username = $row["username"];
$member->password = $row["password"];
$member->logo_filename = $row["logo_filename"];
$member->profile_filename = $row["profile_filename"];
// Next we need to get the listb of additional trades.
$member->additional_trades = [];
$result = DoFindQuery1($g_dbFindATradie, "additional_trades", "member_id", $member->id);
if ($result->num_rows > 0)
{
while ($row = $result->fetch_assoc())
{
$member->additional_trades[] = $row["trade_id"];
}
}
echo json_encode($member);
}
}
else if ($_POST["button"] == "")
{
}
}
?>