Callum Posted August 19, 2008 Share Posted August 19, 2008 HiHow about an expansion of the PHP IF statement section to cover PHP password protection? A simple exampleof how to password protect a page on a website. It is a common request among users and could be fairly usefull as well.Callum Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2008 Share Posted August 19, 2008 There's this:http://w3schools.invisionzone.com/index.php?showtopic=12509 Link to comment Share on other sites More sharing options...
Callum Posted August 19, 2008 Author Share Posted August 19, 2008 Had a look at that, but it's not exactly begginer friendly and the sheer amount of php on the page is daunting unlike the tutorials on the main site.just my 2c Link to comment Share on other sites More sharing options...
justsomeguy Posted August 19, 2008 Share Posted August 19, 2008 Right, but understand that password protection is a decently complex subject. The basics are simple - you compare one password with another one and figure out if they match, which is a single if statement and doesn't need to be any more complex than this: if ($password1 == $password2){ // they match}else{ // they don't match} The details will match your own situation. Like, where are you getting the passwords from? Is the password being looked up in a database, or in a text file, or is it just a hard-coded master password? What do you want to happen if the password check succeeds or fails? Do you want to use cookies or sessions? All of these are questions that you will need to answer, so a tutorial that covers all of that would be more complex than my thread. The example I posted there has code that gets the password from a database (and also registers users), uses the session to keep track if the person is logged in, it will show error messages if they failed the login, etc. So that's just one example. Whatever else you want to happen on your page is sort of up to you, it's not really part of the scope of a tutorial on an if statement. Link to comment Share on other sites More sharing options...
astralaaron Posted August 23, 2008 Share Posted August 23, 2008 Had a look at that, but it's not exactly begginer friendly and the sheer amount of php on the page is daunting unlike the tutorials on the main site.just my 2cJust go through it little by little and understand one thing at a time... this has to be the best tutorial I've seen for beginners. I wish it were around a year or 2 ago! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.