Jump to content

Require User Login


afawcett

Recommended Posts

I am working on a small site, and wanted to password protect it. My teacher's website:http://psy3.ucsd.edu:16080/~psychmickes/psy168.htmldoes a fairly good job of this. Also, even if I send a direct link:http://psy3.ucsd.edu:16080/~psychmickes/psy168su09syl.pdfit requires you to log in. How do I do this? It might be there, but I couldn't find anything in W3 Schools Tutorials.I know she used iWeb, and there is an option to "make site private." Unfortunately I don't have iWeb.

Link to comment
Share on other sites

I am working on a small site, and wanted to password protect it. My teacher's website:http://psy3.ucsd.edu:16080/~psychmickes/psy168.htmldoes a fairly good job of this. Also, even if I send a direct link:http://psy3.ucsd.edu:16080/~psychmickes/psy168su09syl.pdfit requires you to log in. How do I do this? It might be there, but I couldn't find anything in W3 Schools Tutorials.I know she used iWeb, and there is an option to "make site private." Unfortunately I don't have iWeb.
If your webhost uses apache you can google for .htaccess password protect. I don't know how other server applications do it. Often your webhost will have a "password protect directory" option in their control panel.
Link to comment
Share on other sites

Wow, that's perfect. For now this is exactly what I need, but in the future I want to be able to have a members section with a login like these forums or Facebook for example. I'm working on learning PHP and MySQL, can I do it with that?

Link to comment
Share on other sites

You sure can, and it's not really that difficult. All you do, in vague terms, is have a registration form with a username and password field, and you save the username and a hash of the password to the database. A hash is the result of a complex, one way algorithm that creates a uniform length piece of, effectively gibberish from the password. Only that exact sequence of characters can produce the same hash. So when someone signs in, you create a hash of the password from the login form and check it against that in the database. This way, you don't need to actually store the string of someone's password. You can also use the crypt() php function which will do a similar thing. Then, when the user signs in you start a session and store a session cookie. Each page that has member's only content, you check for the presence and of a valid session cookie and if it is present you can display the relevant page data or, if not, redirect them to a public page.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...