So far, the first $sql = “INSERT INTO MySQLtable
statement shown below will insert a new row with static text VALUES ('statictext', 'statictext')
. Question is what is right syntax, method, or whatever to set Encodable variable userName
to php variable $userName
to insert a new row with variable VALUES ('$userName', '$userEmail')
? Tried numerous variations, but so far all insert blank column entries:
// This $sql will insert new row with static text entries:
$sql = "INSERT INTO `MySQLtable`(`userName`, `userEmail`) VALUES ('statictext', 'statictext')";
Solution Update: The Swift JSONEncoder().encode(Post) to the database server, of course first requires decoding the Post to set its contents php variables, so that the following completes the Encodable-php path:
session_start();
$PostContents = json_decode(file_get_contents("php://input"), true);
$userName = $PostContents["userName"];
$userEmail = $PostContents["userEmail"];
$sql = "INSERT INTO `MySQLtable`(`userName`, `userEmail`) VALUES ('$userName', '$userEmail')";