You don't do that last criteria in the same SQL, besides being next to impossible (yes you can do it with Unions and stuff, i know) but it's now how you do it.
You primary key field (the one you want to increment I assume) should be auto_increment. in mysql there is mysql_insert_id() which gives you the last insert in that session.
http://us2.php.net/manual/en/functio...-insert-id.php
postgres should have something similar, I just don't know it.
1. Check user doesn't exist
2. Do your insert
3. Get the last insert id (if you need it)
Dan