How to validate the user entered details based on data present in database

Can anyone help me in validating the fields entered in the form with the details that are already existing in the database.

like entered details and existing details are matched then some functionality need to be performed.

  Discussion posts and replies are publicly visible