beh prova con la funzione mysql_insert_id http://it2.php.net/mysql_insert_id