this controller circuit (AVR as example) . its input is keypad to enter the password from 0 to 9 . the output to relay to either pass the electric when the password is right or don't pass it if the password is wrong . by this you can make several conditions to control the passing of electricity.
if you can't make this , i can help but sorry after 10/6 because i'm now in exams