If I follow this correctly, you want to simply use a foreign key constraint. The key relation will require a record in one table that already has a corresponding key in the second. So this second table would insert all the valid records, then the key relation is placed on the first table, and you simply attempt to insert. If it provides no affected rows after the insert, it will trigger an error indicating a key violation, which is simply the answer for no valid foreign key constraint was satisfied.
If you don't need to store input, than a simple select would tell you if it already exists. It's not clear how you are intending to use the existing disc_id.gamecode in relation to the gamecode via input.
header('HTTP/1.1 420 Enhance Your Calm');