###################################################################### # script: db.cgi # # sub get_email # # # # new subroutine # # # # What it does-- # # Pulls the email address from the password file when a user adds # # a new record. # # # # How to use it-- # # In sub html_record_form, after # # my (%rec) = @_; # # add # # if ($in{'add_form'}) { # # $rec{'Email'} = &get_email; # # } # # # # Be sure to change the word 'Email' above to match exactly the # # name of the field that holds the user's email address. # # # # Important!! # # This only gets the email address for the currently logged in # #user. # # # # ULTRA IMPORTANT!!!!!!!!!!!!!!!!! # # Do NOT use this as the default value for a field in the .cfg file. # # You must use it as above. Leave the default value for this field # # empty. # ###################################################################### sub get_email { # -------------------------------------------------------- # Pulls the email address from the password file. my ($userid, $pw, $view, $add, $del, $mod, $admin, $email); open (PASSWD, "<$auth_pw_file") || &cgierr("unable to open password file. Reason: $!\n"); @passwds = ; close PASSWD; foreach $pass (@passwds) { # Go through each pass and see if we match.. next if ($pass =~ /^$/); # Skip blank lines. next if ($pass =~ /^#/); # Skip Comment lines. chomp ($pass); ($userid, $pw, $view, $add, $del, $mod, $admin, $email) = split (/:/, $pass); if ($db_userid eq $userid) { return $email; } } return "$db_userid not found in password file"; }