IPhone keeps freezing on the lock screen

Last night my iPhone was working just fine, it ran of of battery and then I put it on charge. It loads up to the lock screen and whenever I try to type the pass code in it freezes. Sometimes I can't even type in the pass code. I read online to restore the phone but has anyone got any explanations for this? When the phone is charging it keeps rebooting itself as well, and I have already tried to restart the phone several times.

Try updating your software be a first thing, if its already been updated then the phone has a software glitch and only way is to get it repaired, you could try taking the sim out wait 30 seconds clean it then put back in and then restart the device see if that works if not do as i say