PHP / MySQL Scripts > Simple PHP Password Protect Script
Simple PHP Password Protect Script
Creating a Password protected page on your website.
Do you want to have a hidden page on your website which only people who you give the password to can access it? Most probably you do as we all have something that we want to hide from prying eyes, that is were this PHP password protect page will come in useful
Surprisingly, there are still quite a few hosts that do not allow you to use .htaccess and .htpasswd files to create password protected areas on your website. To overcome this, we can use basic PHP to protect a page and keep our content hidden.
The beauty of this script is that it can be included into any page design and be used to protect just certain areas of a webpage or a full page.
The Simple Password Protect script is written in PHP and will run on any server which supports this. You do not need to use a database, just the simple PHP code which is included in the zip file.
- Download Simple PHP Password Protect Script
- Edit the index.php file and change the password to suit,
- Add the content you want to have protected in the correct section which is fully marked.
- Upload the file to your web server and then point your browser to the uploaded file and try it out.
In Depth Installation
Installation of Simple Password Protect is very straightforward and you just need to download the zip file and upload and/or rename the index.php file and add your content in the correct section of the file.
If you open the index.php file in a web editor you will see that there is a section where you can change the password which gives access to the protected area. Change this to what ever you want and pass this to the people whom you want to grant access to.
Adding the content you want protected
Again, inside the index.php page you will see a section about half way down where you can add the content which you want protected. This could be anything such as, links, contact information, pricelists for customers, family photographs etc. In fact it can be used for virtually anything you want to hide.
One thing to remember is that; do not use any sensitive information such as, credit card information, bank details or very personal details in any protected area. In fact I would go so far to say do not store any sensitive information on any webpage or website which is online. The reason for this is when a surfer sees a password box, it automatically triggers a small switch in the mind that something really good must be protected behind the password box, from this they will try and enter a few common passwords top see if they can gain entry, so always use a mixture so numbers and letters for your passwords.
After reading through this article and downloading the script, you should be able to add a password protected section to your website. Any problems with this script or any other, please feel free to use the forums for assistance.