How To Create a Password Protected Page
Let's say you would like to password protect a page in your site. You don't have to install a software or protect a whole directory to just protect a single page. There is an easier and quicker solution that you can apply. This password protect tutorial explains you how to easily create a password protected file in couple of lines. Whether you have a content that you only want give access to people you choose, or whether you would like to have a page for only yourself in your site. This is a copy and paste quick solution.
The first step will be changing you filename to "password-protected.php" from "password-protected.html", since we will be using PHP to protect your page. Changing the filename to PHP will not affect your page, it simply tells your web server to look for PHP codes inside your page. If you have none, it will as same as any other HTML file.
Now, we will add a simple PHP code into password-protected.php page, so that it will be protected. Open the file with a text editor and place these lines into the beginning:
That's all. Upload the file into your server and call it like this:
You will not be able to access to the page. Now try adding the password like this:
This is one of the simpliest ways to password protect a page. Our next tutorial will desribe a more detailed password protection on pages. You may also follow our tutorial and password protect a directory.