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.

2 thoughts on “Add authentication to any php page the easy way”

  • 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?

  • 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.
    Regards
    David Beale

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>