#!/usr/bin/perl -w use CGI qw(:standard -debug); use CGI::Pretty ":standard"; use CGI::Carp qw(fatalsToBrowser); ########### Credits ################# # Script written by R. Todd Vandenbark ##################################### # -------------------------------------- # Takes input from findstaff.cgi, # creates pre-populated form for # editing staff system user's info. # Calls updatestaff.cgi to insert # info into staff.txt file. # -------------------------------------- #---------- define variables ------------ # == form input variables == my ($staff,$bsuname,$username,$passwd); my $css = ''; # == script variables == my $inputfile = "../../staff.txt"; my $tempfile = "../tempfile.txt"; my @inarray=(); # array to read in file # ---- end define variables ------------- # ---- process input ----- $staff = param("staff"); chomp $staff; ($bsuname,$username,$passwd) = split (/:/, $staff); if (!$staff) { # if no selection made, generate error msg $title = 'oops...'; print header(); print start_html(-title => $title, -head => $css, -class => 'oneColFixCtrHdr'); print '
'. "\n"; print '
'. "\n"; print h2("Please select item for editing"); print "\n". '

Go back to list.

'. "\n"; &footerprint(); exit; } # -------------------------------------- # create temp file of all other records # to be appended-to in updatestaff.cgi # -------------------------------------- open (MEGADATA, "$inputfile") || die "Can't open $stafffile: $!\n"; @inarray = ; chomp @inarray; close MEGADATA; # close input file open (TMPMEGADATA, ">$tempfile") || die "Can't open temporary file $tempfile: $!\n"; foreach $key (@inarray) { my ($bsuname2, $username2, $passwd2 ) = split(/:/,$key); if ($bsuname eq $bsuname2) { # found match next; # skip adding record to temp file } else { $tmpout = join(":", $bsuname2, $username2, $passwd2 ); print (TMPMEGADATA "$tmpout\n") || die "Error writing $tempfile: $!\n"; } # append non-matching record to file } # ---- end while ---- close TMPMEGADATA; # close temp file # ----- create editing form ------- $method = 'post'; $action = 'updatestaff.cgi'; $encoding = 'application/x-www-form-urlencoded'; my $title = 'Update staff information'; $logo = ''; print header(); print start_html(-title => $title, -head => $css, -class => 'oneColFixCtrHdr'); print '
'. "\n"; print '
'; print p("Please edit information, then click the UPDATE button."); # ---- form ------------------------ print startform($method,$action,$encoding); print qq{
   
}; print end_form; print <
Report a problem.
Main menu. Help function EOF &footerprint(); # ---- subroutines used ---------------------------------- sub footerprint { print '
'. "\n" . ''. "\n" . '
' . "\n"; print end_html; }