PHP: Password Protect Your pages.

Contributor Icon Contributed by William_Wilson  
Tag Icon Tagged: PHP programming  

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, will not reveal your password, and 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: william_a_wilson@hotmail.com
-William. ยง (marvin_gohan)

 

1 Comment -


  1. Anonymous said on May 2, 2011

    This is very useful instruction about security. Also, PHP is best language and Itis best security facility provide for use.

    toshiba coupon codes

 

RSS feed for comments on this post. TrackBack URL

Leave a comment -