I am able to get error http codes displayed. But my success header doesn't display. I've tried 5 different ways am now stuck. They are successful, it adds to the database.
I've tried header("HTTP/1.1 200 OK"); http_response_code(200) I changed else then the success code to another if statement.
<?php
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$conn=new PDO("mysql:host=localhost;dbname=kgraves;", "kgraves", "Ahph1ieg");
$review= $_POST["review"];
$poi_id = $_POST["poi_id"];
$id= $_POST["id"];
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$results =$conn->query("INSERT INTO `poi_reviews`(`id`, `poi_id`, `review`) VALUES ('$id', '$poi_id', '$review')");
if(empty($results))
{
header("HTTP/1.0 404 Not Found");
}
if(!$results)
{
header("HTTP/1.0 200 Success");
}
}
if(isset($_POST['submit']))
{
if ($review == "")
{
header("HTTP/1.0 404 Not Found");
}
}
if(isset($_POST['submit']))
{
if ($poi_id == "")
{
header("HTTP/1.0 404 Not Found");
}
}
if(isset($_POST['submit']))
{
if ($id == "")
{
header("HTTP/1.0 404 Not Found");
}
}
?>
Would like to know what I'm doing wrong! I've completed more complicated code it's obviously something silly I just don't understand.