PHP: Password Protect Your Pages

Posted June 25, 2006 by admin in PHP programming

Last Updated on

This tutorial contains a simple PHP implementation which will prevent unwanted access to certain pages.

Simply place your page inside a large PHP if statement:

if($_POST['password'] == 'Any_Password_You_Like'){
<!--html code for page goes here -->
} else {
<script language=javascript>"");

The code is translated server side and will not reveal your password. It will generate either the page protected or apply the else, which re-directs to a default page. The default segment could also be written in PHP and simply echo text to the screen.

Questions/Comments: [email protected]
-William. ยง (marvin_gohan)

The Conversation

Follow the reactions below and share your own thoughts.