HomeWeb application programmingPHP programmingPHP: Password Protect Your Pages

PHP: Password Protect Your Pages

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:

<?php
if($_POST['password'] == 'Any_Password_You_Like'){
?>
<!--html code for page goes here -->
<?php
} else {
?>
<script language=javascript>
window.open("http://www.yoursite.com/default.htm");
</script>
<?php
}
?>

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)

RELATED ARTICLES

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -

Most Popular

Recent Comments

Cleveland Furia on How to Clear Google Activity
Sid Wohlfarth on How to Clear Google Activity
Riley Magsayo on How to Clear Google Activity
สมัครรับเครดิตฟรี ทันที on How to improve Remote Desktop Protocol Performance
Neal Wangstad on How to Clear Google Activity
Slavcho Andov on How to install Ubuntu
Slavcho Andov on How to fix bad sectors
Sheraz Ali on How to Backup Android