Añadir película y categoría

<?php
 $server = "localhost";
 $user = "root";
 $password = "";
 $db = "sakila";

try {
 $conn = new PDO("mysql:host=$server;dbname=$db", $user, $password);
 $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$conn->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
 $conn->exec("SET CHARACTER SET utf8");

$category = filter_input(INPUT_GET, "category", FILTER_VALIDATE_INT);
 $film = filter_input(INPUT_GET, "film");
 if (!empty($category) && !empty($film)) {
 $sql="insert into film(title,language_id) values ('$film',1)";
 $conn->exec($sql);
 $film_id=$conn->lastInsertId();
 $sql="insert into film_category(film_id,category_id) values($film_id,$category)";
 $conn->exec($sql);
 }

$sql = "select * from category";
 $q = $conn->query($sql);
 $categorias = $q->fetchAll();
 } catch (PDOException $e) {
 echo "Connection failed: " . $e->getMessage();
 }
 ?>
 <form>
 Categoría: 
 <select name="category">
 <?php foreach ($categorias as $categoria) {
 ?>
 <option value="<?= $categoria['category_id'] ?>"><?= $categoria['name'] ?></option>
 <?php } ?>
 </select>
 <br/>
 Película: <input type="text" name="film"><br/>
 <input type="submit">

</form>