-help- rfid with sonar sensor and display door lock

when the door is at a certain distance (really close) the door would lock

Distance to what? Use a microswitch to determine if the door is shut, then lock it.

this code is mostly parts taken from other things mashed togeither to make something.

Not a good idea. You should make sure that every part of the project (sonar, door lock) works on its own, and that you understand it, before putting several things together.

We strongly recommend that you try out the simple examples that come with the Arduino program development software, to learn the language and the special features of the Arduino, before tackling a complex project like this.