I'm using this code to pass the userName variable...
return fetch('http://creat1vedesign.com/userTabs4.php', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
}, {
body: JSON.stringify({
userName: 'carolf'
}),
...to this php script...
<?php
include 'DBConfig.php';
$con = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);
$json = file_get_contents('php://input');
$obj = json_decode($json,true);
$userName = $obj['userName'];
$sql = "select * from Users where userName = '$userName'";
if ($result = mysqli_query($con,$sql)) {
while($row[] = $result->fetch_assoc()) {
$tem = $row;
$json = json_encode($tem);
}
} else {
echo "No Results Found.";
}
echo $json;
$conn->close();
?>
...to retrieve data for a specific criteria. But either the React Native is not sending the data or the php script is not receiving it or the syntax is incorrect or I'm doing something else wrong :(
Any thoughts?