Generate automatic ids after user submits and display it

Hi everybody. I have a dynamic page that displays 1 item from a category page . I have a user input form that needs to generate a unique id(Reservation_ID) when a user clicks the submit button of the form and have it save to a database called “Bookings”. I must also have the same id displayed on a new page after the submit button is clicked. Your help is much appreciated.