My question is, how do I insert the current ID of my Game ID into the database. Here is my table: game_review mySQL
I want to insert the current user_id and title and description, which i already know how to do. (I'm not worrying about errors checking or security yet.) I just cannot insert the current ID of the game that I clicked on.
Here is my code:
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/Gamesite/core/init.php';
include('head.php');
include('navigation.php');
?>
<div class="container" style="padding-top: 200px;">
<?php
// Get the current ID of the game
$game_id = $_GET['id'];
$errors = array();
// Get the user ID from init.php
$user_id = $user_data['id'];
if (isset($_POST['submit'])) {
// Sanitize form fields.
$title = ((isset($_POST['title']) && $_POST['title'] != '') ? sanitize($_POST['title']) : '');
$review = ((isset($_POST['review']) && $_POST['review'] != '') ? sanitize($_POST['review']) : '');
$rating = ((isset($_POST['rating']) && $_POST['rating'] != '') ? sanitize($_POST['rating']) : '');
if (!empty($errors)) {
display_errors($errors);
} else {
$SQL_INSERT = "insert into game_review (`user_id`, `game_id`, `rating`, `title`, `review`) VALUES ('$user_id', '$game_id', '$rating', '$title', '$review')";
$QUERY = $db->query($SQL_INSERT);
//header('Location: Review.php');
}
}
?>
When I click submit in the form, this error message show up.
Notice: Undefined index: id in C:\xampp\htdocs\Gamesite\game_includes\Review.php on line 14
It says this question is a duplicate, can you please redirect me to a similar answer to my question?
Im sorry, I looked at that question that you redirected me, but thats not the question I was asking for.