Wordpress website - check if string exists in database

I make website for one pharmaceutic company, and on search page person nned to check if product code is valid. There are about 10 000 codes like this:

3bktzgo4
2ltold4k
4u93l4r
sm9yngpj

I need to visitor when search one of code, if code exist in database to be written that product is valid, else, if code do not exist, to be shown that product is counterfeit.

Does anyone know how to make it, with php, or js or with some plugin, in the simplest way?

http://royallabindustries.com/verify/