I am doing a signup form with an INSERT
SQL query using PDO. After this INSERT, I want to extract the userid
(auto incrementing, primary key) that
lastInsertId() returns the identifier of the last row inserted on that connection, so concurrent users (with different connections to the database) will not interfere.
You can avoid this by doing a select by the email or some unique field. That will guarantee you get the correct user id.
For example:
select id from user_table where email = 'user@email.com' limit 1;