Advanced Search

Results 1 to 2 of 2

Thread: Password Protection

  1. #1
    Join Date
    Sep 2004
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Password Protection

    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.

    Thanks,
    Rob

  2. #2
    Join Date
    Sep 2004
    Location
    Indonesia
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I don't think this thread belongs here But I'll reply it anyway...
    This is an example of a very, very, very simple password authentification using php :
    Code:
    <?php
    if (!isset($_POST['submit'])){  //if the form isn't posted yet
    ?>
    <html>
    <head>
    <title>login</title>
    </head>
    <body>
    <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">
    </form>
    </body>
    </html>
    <?
    }
    else {     //the form is posted
    	if ($_POST['answer'] == "red")        //if the aswer is red
    	    header("location:member.html"); //go to members area
    	else
    	    header("location:" .$PHP_SELF); //else, show login form again
    }
    ?>
    Last edited by gigabites; 09-27-2004 at 01:38 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •