Main Content

Simple page password protection - PHP

Archive - Originally posted on "The Horse's Mouth" - 2007-10-04 08:16:44 - Graham Ellis

So many demonstrations are too clever - the wood gets lost for the trees and the newcomer is left not knowing what the important bits are. So a request overnight for a REAL simple way of password protecting some content based on a single password that can be changed [in the code] from time to time provided me with an opportunity to provide a new training example and to fill in the gap in really easy examples.

There's a script here and when you first call it up, you're asked for a password. Enter "abc123" and the same URL will give you back the protected content. If you want to see the source, look here.

Is it a thorough script? NO! You need to log in each and every time. Single password only. No facility for changing password without altering the page. No way to register or get password reminders .... but you don't always want a thorough script with all these bells and whistles, do you?