Loading ...
Sorry, an error occurred while loading the content.

Create a database (in Perl) to store names and passwords

Expand Messages
  • Kyle Hamar
    ... I also have been working on this problem (while reading this list for clues on occasion.) I installed various forms of sql but eventually decided that the
    Message 1 of 2 , Mar 7, 2002
    • 0 Attachment
      At 02:48 PM 3/7/2002 +0000, you wrote:
      >How would I create a database (in Perl) that could store user names
      >and passwords?
      >I then would like to use it on a website so members can log in.I know
      >this would use cgi of some form, but how would I use the database to
      >do so?
      >Finally(but not essential), it would be a nice touch if non-members
      >could sign up (i.e. update the database from the website) - is this
      >possible??If so how??

      I also have been working on this problem (while reading this list for clues
      on occasion.) I installed various forms of sql but eventually decided that
      the number of log-ins would not be sufficient to require anything more
      complex than comma separated text files. Besides this, my host charges a
      fee to setup (link) my account to sql. Does anyone know a way around this
      with pure perl cgi?

      See DBD::CSV for a simple text implementation. I have all but decided to
      write my own simple text file DB routines. The simple
      username:password:email format did not seem to require anything more.

      My project now is to create a resume and job posting site. Very quickly I
      discovered what a huge undertaking this is. The overall issues seemed to be;
      - User Login and Registration
      - What format should this be in?
      - How do I validate user information?
      - How do I check for duplicate users?
      - How does email validation work?
      - Should passwords be stored on site or via MD5 hash?
      - How do I set a cookie to recognize returned visitors?

      - Job Posting
      - Major form design project here!
      - What format should the data be stored in?
      - How do I efficiently search these and display them properly?

      - Resume Posting
      - Major form design project here!
      - User specific 'pages' for information review and update
      - What format should the data be stored in?
      - How do I efficiently search these and display them properly?

      I am a perl 'hacker' and not very efficient with code. My code does work
      though I sure the experienced users here would point out my numerous flaws.
      Experiment with the following subroutine.

      use strict;
      use warnings;
      use CGI qw(:standard);

      print header(), start_html("Welcome new user"), i("Welcome New User");
      my $name = param("name");
      my $email = param("email");
      my $password = param("password");
      my $md5 = "future use"; #detail removed

      writeuser("users.txt",$name,$password,$email, $md5);

      sub writeuser {
      my $datafile = shift;
      my $n = shift;
      my $p = shift;
      my $em = shift;
      my $emmd5 = shift;
      print p("WRITEUSER SUBROUTINE BEGIN");
      print p("Datafile is $datafile \n");
      print p("Name is $n \n");
      print p("Password is $p \n");
      print p("Email is $em and md5 is $md5 \n");
      open (FH, ">> $datafile");
      print FH $n,":",$p,":",$em,":",$md5,":","no\n";
      close FH;
      print p("========> WRITE COMPLETE <========== \n");
      print p("You have added a user to $datafile \n");
      return
      }




      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.