dopo la query insert

mysql_insert_id
(PHP 3, PHP 4 , PHP 5)

mysql_insert_id -- Ottiene l'identificativo generato dalla precedente operazione INSERT