Add authentication to any php page the easy way

This is useful for anyone who’d like to add a login form to any php page.

Simply, save the following code as access.php, and insert the following snippet on the first line of any php file you want protected.

< ?php include “access.php”; ?> (remove the space before the question mark)

Voila! as easy as 1,2,3. The crentials can be edited in the access.php file, by changing the values of $ADMIN_USER and $ADMIN_PASSWORD.

This useful script requires no database, and no big tweaking to the code on your pages.

4 Responses to “Add authentication to any php page the easy way”

  1. Pete says:

    Is there a why to make it where it checks the passwords online, instead of using only one log on, so you can have multiple logons available to advance, instead of just one, the one in the config?

  2. rajesh says:

    We create quality websites with full features and full responsve for small and large business. This website affordable, easy to maintain and with the flexibility to grow with your business needs.
    We offer best website design and development services to those looking for an experienced, thoughtful and creative website. We listen carefully to your requirements and develop a website that delivers 100% of the features you need, with none of the costly extras you don’t need.
    We develop a clean, sharp, professional website design that will adapt to the future growth of your business. You have found your answer with our professional web design services. Here your plans meet with our passion for design and your dreams match our dedication to providing unique, customized web design services that turns your vision into success.
    We provide Static, Dynamic, Portal and Ecommerce site at lowest price. Contact –, 8285530031

  3. Whaooh! This is right on time. I guess this will solve my problem with pages authentication

  4. David Beale says:

    This looks nice, thanks; I’ll try it.
    The form is perhaps too soon because I haven’t loaded or used the system yet…but I’ll save it and comment later.
    If you get few people filling out the form it’s ok they probably lost the source of the script.
    David Beale

Leave a Reply