View Full Version : Password Protection

09-27-2004, 12:19 AM
I'm looking to have a password input field on one of my pages in my website, but instead of having seperate user id's and passwords for everyone, i just want a question that only my friends would know, and when they enter the right word they can go to the selected page. If they enter the wrong word they get an error page, or get redirrected to another page. I know the code for the input field is <input type=password> but i dont know how to make the CGI (thats whats required, right?) script that allows for the options. Any help would be greatly appreciated.


09-27-2004, 01:28 AM
I don't think this thread belongs here :p But I'll reply it anyway...
This is an example of a very, very, very simple password authentification using php : :)

if (!isset($_POST['submit'])){ //if the form isn't posted yet
<form method="post" action="<?=$PHP_SELF;?>">
question : What is my favourite color?<br>
answer : <input type="pasword" name="answer"><br>
<input type="submit" name="submit" value="submit">
else { //the form is posted
if ($_POST['answer'] == "red") //if the aswer is red
header("location:member.html"); //go to members area
header("location:" .$PHP_SELF); //else, show login form again