There is a basic example of the gform_pre_submission hook on it's documentation page here:
You are correct that you'll need to query the wp_rg_lead_details table.
As for how you can cancel the submission, what would be an example of a scenario where you would want to do so that way I better understand what you are trying to implement? Do you want to show a validation error or do you want to show a message and hide the form?
To notify the user that the submission is canceled, and the response returned to the user on the screen isn't sufficient, you can write PHP to send an email to that user if one of the fiels is an email field or if they are logged in user you can use their user account email address.
Posted 7 years ago on Tuesday December 6, 2011 | Permalink