How do I retrieve some data based on ID?

how to retrieve data automatically in the form of gravity?

The work flow is as follows:
First the user submits basic data such as name and email, then when the user wants to fill in the second form, some fields in the form are filled in automatically such as name and email based on the id chosen by the user.

Thank you

You can do that with the gform_field_value filter:

To retrieve information from the database from your existing entries, you can use the Gravity Forms API functions: