Are there any potential security risks associated with the current implementation of the dynamic year selection in PHP?

The current implementation of the dynamic year selection in PHP may be vulnerable to SQL injection attacks if user input is not properly sanitized. To mitigate this risk, it is important to use prepared statements and parameterized queries when interacting with the database.

// Assuming $year is the user input for the selected year
$year = $_POST['year'];

// Using prepared statements to prevent SQL injection
$stmt = $pdo->prepare("SELECT * FROM table WHERE year = :year");
$stmt->bindParam(':year', $year, PDO::PARAM_INT);
$stmt->execute();