So I have been trying at this for hours, and looked all over but cannot find a way to make it work. I know that the issue is related to _POST and _GET, however I can't seem to fix it. Every time I click the submit button, I get an error thrown that tells me my query has all of the information except for $ID, which is blank. When I echo above the statement, the ID is correctly retrieved from the URL and displays the correct number, however when I try to insert the variable into my query it inserts nothing. When I switch the isset statement to check for a value in id, it doesn't run, meaning id isn't defined in the _POST array. How could I make my query contain the ID as well as all the other data?
<?php
require_once 'login.php';
$conn = new mysqli($hn, $un, $pw, $db);
if($conn->connect_error) die($conn->connect_error);
$id="";
if (isset($_GET["id"]))
$id = $_GET["id"];
echo "$id";
if (isset($_POST['title']) &&
isset($_POST['score']) &&
isset($_POST['body']) &&
isset($_POST['date']) &&
isset($_POST['customer']))
{
$title = get_post($conn, 'title');
$score = get_post($conn, 'score');
$body = get_post($conn, 'body');
$date = get_post($conn, 'date');
$customer = get_post($conn, 'customer');
$query = "INSERT INTO review VALUES" .
"(NULL, '$title', '$score', '$body', '$date', '$id', '$customer')";
$result = $conn->query($query);
if (!$result){
echo "INSERT failed: $query<br>" .
$conn->error . "<br><br>";
}else{
header("Refresh: 0; URL= AddReviewSuccess.php");
}
}
echo html......
......FORM DATA THAT HAS method='post'......
......end echo
function get_post($conn, $var){
return $conn->real_escape_string($_POST[$var]);
}
?>