Please turn on javascript in your browser to play chess.
Developers Forum

Developers Forum

  1. 26 Aug '05 18:57
    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.
  2. 26 Aug '05 19:00
    Well, it's a big vague... but a database back end is really what you would like. They create new users in the DB, edit preferences, etc..

    You can do it with either php or perl. I'd do it with perl, you get more ladies that way...
  3. Subscriber Russ
    RHP Code Monkey
    26 Aug '05 20:05
    Tell me your great idea, then I rip it off and become a millionaire. But, at least you get to see your vision without lifting a finger.

    -Russ
  4. 26 Aug '05 20:26 / 1 edit
    Originally posted by Russ
    Tell me your great idea, then I rip it off and become a millionaire. But, at least you get to see your vision without lifting a finger.

    -Russ
    My great idea has already been done by me twice, but at about 1/4th the efficiency of if I had a place for "contestants" to log in and have accounts.
  5. 05 Jan '06 00:24
    Originally posted by Morren
    You can do it with either php or perl. I'd do it with perl, you get more ladies that way...
    Nah, already tried but they prefer pearls (the ones I have met anyway).
  6. 07 Jan '06 16:04 / 3 edits
    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:

    color=red&html_emails=0&sex=mail

    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/

    Good luck.

    *) 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.