Simple Password Protection Using PHP
Join the DZone community and get the full member experience.Join For Free
Use this simple script to password protect your pages, Ideal for password protecting Administrative parts or sensitive parts of your web site. The logic behind the script is very simple when ever your password protected page is called the script is first called it checks for the username and password if not found, presents you with a login page and when you submit info (username, password) it checks if the info is correct if correct allows you to access the protected page, else denies access. To protect a particular page use the include directive to include this script in your page.Example:
: Authentication Required
(Access Restricted to Authorized Personnel) $host : Administration
You Need to log on to access this part of the site! "; echo "Error: You are not authorized to access this part of the site! Click here to login again.