homepage Welcome to WebmasterWorld Guest from 23.23.12.202
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Simplist Possible Unsecure Password Script
A database is not needed
successfirst

5+ Year Member



 
Msg#: 3355749 posted 1:55 pm on Jun 1, 2007 (gmt 0)

Hi,

Could you please tell me what the simplist unsecure password script is? I don't need a database. All I need someone to do is enter a password and be redirected to a new page if the password is correct.

I would really appreciate it.

Brandon

 

eelixduppy

WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3355749 posted 2:02 pm on Jun 1, 2007 (gmt 0)

Assuming you are only allowing one password, something like this is as simple as it gets...

if($_POST['password'] == 'correct_password') {
header("Location: http://www.example.com/redirected_page.html");
exit();
} else {
echo 'You did not type in the correct password';
}

Oh course, you post a form to this page with something like the following:

<input type="text" name="password" />

If you are gonig to want to incorporate multiple passwords, you are going to have to take a silghtly different approach.

Just a quick note here. The redirected page is NOT secure, and anyone can see it if they type in the uri into the browser. To make it secure you can set a session variables and make sure it exists on the redirected page, or you can echo out the information to the browser right after the password check, instead of using the header*() redirect.

Good luck

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3355749 posted 2:05 pm on Jun 1, 2007 (gmt 0)

you could also just set up htaccess

eelixduppy

WebmasterWorld Senior Member eelixduppy us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3355749 posted 2:17 pm on Jun 1, 2007 (gmt 0)

Yes, which is probably a better solution in this case.

you could also do http authentication through php: [php.net...]

:)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved