Post: [php] simple password protect
05-10-2011, 01:21 AM #1
(adsbygoogle = window.adsbygoogle || []).push({});
Originally posted by 039

Want to password protect a portion of your website?

<form name="pp" method="post" action="checkpass.php">
<input type="password" name="pass">
<input type="submit" value="Log In">
</form>

Ok we have a form and an input, called pass.
When they click Log In it will take them to checkpass.php

So in checkpass.php we have the following:


<?php
if ($_POST['pass'] == "PasswordHere") {
include ("protected.php");
}
else {
header("Location: notright.php");
}
?>


So this is an if and else statement, replace PasswordHere with the password you want to use!

If the password in the form and your password match then it will keep checkpass.php but actually load inside it protected.php
If its wrong it will redirect them to notright.php
source You must login or register to view this content.
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo