Register now or log in to join your professional community.
Use LAST_INSERT_ID() from your SQL query or you can also use mysql_insert_id() to get it using PHP.
LAST_INSERT_ID() can be used to fetch latest auto increment id being used in any INSERT query that was just got executed.