Two ways to do it, use pg_last_oid and then run a select id from table where oid=$oid OR just fetch the sequence output yourself right before the insert and do it by hand.
select nextval('seqnametoserialfield');
insert into table (info,id) values ('$text',$id);
DO NOT do select max(id) as that is possibly the most likely to cause your data to get goofed up. It's a race condition extraordinaire.
C1: insert into table values ('infohere');
C2: insert into table values ('moreinfo');
C1: select max(id) from table;
C2: select max(id) from table;
C1: insert into table2 values ('infotogowithc1sprevious insert',id1);
C2: insert into table2 values ('infotogowithc2sprevious insert',id2);
The problem being that C1 is now inserting data against the record C2 inserted, not the master record C1 inserted.
The only way to make the max() work safely is to do the whole thing inside of a serializable mode transaction which sucks for performance.
doing it the way monk proposes is like walking around with a gun pointed at your foot. It's not guaranteed you'll shoot yourself in the foot, but each day you do it, the chances go up.