i want to migrate this code to use pdo
The form have a auto complete field nuts3 and the other two values are zip code and locality based on nuts3 value it also inserts nuts2 and nuts1
<?php
require_once ("/includes/config.php");
$cp = $_POST['insert_cp'];
$localidad = $_POST['insert_localidad'];
$nuts3 = $_POST['nuts3'];
$insert = "INSERT INTO codigopostal (cp,localidad,fk_nuts3_id,fk_nuts2_id,fk_nuts1_id,fk_pais_id) VALUES ('$cp','$localidad',(SELECT nuts3_id FROM nuts3 WHERE nuts_3 = '$nuts3'),(SELECT fk_nuts2_id FROM nuts3 WHERE nuts_3 = '$nuts3'),(SELECT fk_nuts1_id FROM nuts3 WHERE nuts_3 = '$nuts3'),(SELECT fk_pais_id FROM nuts3 WHERE nuts_3 = '$nuts3'))";
if ($dbconn->query($insert) == TRUE){
$last_id=$dbconn->insert_id;
echo "ID CP:" . $last_id;
} else {
echo "Error: " . $insert . "<br>" . $conn->error;
}
mysqli_close($dbconn);
?>
the official documentation and the calories example dont make any sense so far for me