What are some potential security vulnerabilities in the PHP script provided, especially in relation to handling user input like $_GET variables?

One potential security vulnerability in the PHP script is the lack of input validation and sanitization for user-provided data in the $_GET variables. This can lead to various attacks such as SQL injection, cross-site scripting (XSS), and remote code execution. To mitigate these risks, it is essential to validate and sanitize all user inputs before using them in the script.

// Validate and sanitize user input from $_GET variables
$id = isset($_GET['id']) ? filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT) : null;

if($id !== null){
    // Proceed with using the sanitized input
    // For example, querying the database with the sanitized $id
} else {
    // Handle invalid input, such as displaying an error message or redirecting
}