I created the following scripts to send data to server, but when I use postman to send data in json format it sent blanks data, the following are my scripts
<?php
header("Content-Type: application/json; charset=UTF-8");
//open connection to mysql db
$connection = mysqli_connect("localhost","wamesh","wames9est","wam90est")
or die("Error " . mysqli_error($connection));
// recieved from app
$mtitle = $_POST['mytitle'];
$mdate = $_POST['mydate'];
$mnews = $_POST['mynews'];
echo "Response: ".$mtitle." ";
$sql_query = "INSERT INTO news (title,news,time) VALUES ('$mtitle','$mnews','$mdate')";
if (mysqli_query($connection, $sql_query)) {
echo "We just posted a news response!";
} else {
echo "Error: " . $sql_query . "<br>" . mysqli_error($connection);
}
mysqli_close($conn);
?>
and this is a sample of data I try to send
{
"mytitle": "COVID 19 Updates",
"mynews": "COVID 19 - Breaking News",
"mydate": "19 may 2020"
}
in postman it shows success but in database I just found row added but no values inside.