In PHP/MySQL, what’s the best way to generate a unique reference ID so that when a person submits his info to the database, he gets a reference number to follow up with his request?
I am already using the auto-increment feature from the database since the data needs to be unique every time a user submits information, but then I need to pick that specific data from the database in order to retrieve that incremented value and display it with PHP.
If you want to use the auto_increment value you can execute
select last_insert_id()after your insert.last_insert_id() is a mysql function that returns the auto increment value from the last insert.
As others have noted some mysql libraries provide their own method for getting the last insert id