I don't understand your logic. If id_propiedad on table 1 is the primary key and auto increment why are you passing it in your form data?
You should insert the record without the id and let the database generate the next one for you.
Change this line:
$query = "INSERT INTO midatabase.t_propiedades (id_propiedad,regimen, localidad, isla, tipopropiedad, zona, amueblado, habitaciones, estado, baños, cocina, salon, terraza, aseos, metros, descripcion, precio, precio_oferta, novedad, destacada)".
"VALUES ('$idpropiedad', '$regimen', '$localidad','$isla','$tipopropiedad', '$zona','$amueblado','$habitaciones','$estado','$baños','$cocina','$salon','$terraza','$aseos','$metros','$descripcion','$precio','$precio_oferta','$novedad','$destacada')";
To:
$query = "INSERT INTO midatabase.t_propiedades (regimen, localidad, isla, tipopropiedad, zona, amueblado, habitaciones, estado, baños, cocina, salon, terraza, aseos, metros, descripcion, precio, precio_oferta, novedad, destacada)".
"VALUES ('$regimen', '$localidad','$isla','$tipopropiedad', '$zona','$amueblado','$habitaciones','$estado','$baños','$cocina','$salon','$terraza','$aseos','$metros','$descripcion','$precio','$precio_oferta','$novedad','$destacada')";
AND stick the other code in I mentioned earlier.