Password generation and validation from database

I'm trying to make a method of password validation for an assignment that wants me to only allow passwords containing 'NT' followed by the last 6 digits of an existing student ID (eg. NT123456). The user will enter their last name and password on the first page, and I will run it through a query. From there if the record count is greater than 0, they were redirect to a portal, otherwise they will be told it was incorrect, but that isn't as important right now.