If I do not fully understand your question, you do not need a trigger for this - just use the "last inserted identifier" functionality of your database driver.
Here is an example using the base mysql driver in PHP.
<?php
$db = mysql_connect( 'localhost', 'user', 'pass' );
$result = mysql_query( "insert into table (col1, col2) values ('foo', 'bar')", $db );
$lastId = mysql_insert_id();
This is a secure connection method for obtaining an identifier.
source
share