Originally posted by Coconut
Say I were to want to make a site, where people can sign up, and have usernames/passwords to go in and edit certain preferences. Where would I start with this. Would I want to learn some php? This kind of thing cannot be too hard for a simple structure.
Well, here's a simple example.
Create a database* in your preferred DBMS. Create tables with the following fields:
ID - integer
name - username
pass - sha1(username+password)
preferences - Text
Now, preferences can be in any format you like, but this is an example:
and so on. It's a basic GET string as you can see in the address field of your browser.
Now, write a class or just a set of functions in PHP or Perl or Ruby or Java or whatever language you prefer. PHP is
very easy to learn if you have no previous experience programming.
Logging in is easy. Receive username and password from the user (I assume you know that you will have to create an HTML input form for this to work?) and put them through a sha1 function. You'll get a string with 32 characters in it. Compare that string to the pass field in your table:
SELECT preferences FROM [table] WHERE pass=[your 32 character string]
Now, if you get a result, the user existed and supplied the correct information, and if not (s)he didn't exist and you do whatever you need to (like resend the login form).
Assuming the user is valid, you can split the string in preferences by the ampersands (& ) and then split the resulting substrings by the equal-signs. Put the values in variables by the same name, and your application can do whatever it needs to do with it.
If you're using PHP, you may want to take a look at the following manual entries: sha1, split.
You can also use the list construct to set the variables directly from the preferences string, and then clean the variables up afterwards (if you know the preference variables beforehand).
All the information you need is available at http://www.php.net/manual/en/
*) If you have a small community and don't expect it to grow, you can even use simple files. Then name the files after the sha1 key.