GetSimple Support Forum
Password Protected Page - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Feature Requests (http://get-simple.info/forums/forumdisplay.php?fid=7)
+--- Thread: Password Protected Page (/showthread.php?tid=647)



Password Protected Page - badcat - 2010-04-17

Anyone have any ideas for how to create a password protected page? Or possibly a redirect to a "hidden" page (not listed in the menu)? or a Plugin?

thanks!


Password Protected Page - n00dles101 - 2010-04-17

Hey,

This is how I did it on one of my sites, needed some quick and easy.
You'll need Customfields plugin installed... setup a new field as a dropdown with one option"protected"
and a second textfield called "password"


Change your template file where you echo the page content to

Code:
if (returnCustomField('pagetype')=="protected"){
                include "protected.php";
            }
             else {
                get_page_content();
            }

The content of protected.php is

Code:
<?php

$password=(isset($_POST['password']) && $_POST['password']!= '') ? $_POST['password'] : '';
$realPassword=returnCustomField('password');
$err="";

if ($password!="" && $password!=$realPassword){
    $err="Password Incorrect";
}

if ($password==$realPassword){

get_page_content();
    
} else {


?>
<div style="text-align:center;"><br/> <br/>
<h2 style="margin-right:0px;">Welcome to the VIP area.</h2>
<br/>

<br/>
<form action="index.php?id=vip" method="post">
Please enter your Password:
<br/> <br/>
<input type="password" name="password" id="password"  /><br/>
<input type="submit" value="Enter" />
</form>
<?php
if ($err){
    echo "<p class='passFail'>".$err."</p>";    
}
?>

</div>

<?php
}
?>



Could probably be coded a lot better but he needed something fast and this works for him...

Hope it helps...

Mike....


Password Protected Page - badcat - 2010-04-17

n00dles101 Wrote:Hope it helps...

As ever, awesome! Thanks - will try it out.