Write

#!/usr/bin/perl -w

#####################################

# Script by Joseph W. Guillaume #

# All Rights Reserved #

# June 17, 2005 #

#####################################

use strict;

use CGI qw(:standard);

print "Content-Type: text/html\n\n";

print '<body bgcolor="cccccc">';

#####################################

my $employee =param('employee_name');

my $certification =param('certification');

my $extra_email =param('extra_email');

my $month =param('month');

my $days =param('days');

my $year =param('year');

my $date ="";

my $mo_yr ="";

my $mo;

my $yr;

my $number;

my $lines="";

my $i;

my $ii;

my $mon;

my $data;

my @data;

my $x_certification;

my $x_extra_email;

my $x_month;

my $x_day;

my $x_year;

my $x_mo_yr;

my $spacer ="<table width=600 border=0 cellspacing=0 cellpadding=0 height=100><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td></tr></table>";

my @mon = qw (January Feburary March April May June July August September October November December);

$month =($month+1);

$mo = $month;

$yr = $year;

############################################################

# Input Error Checking not need using JavaScript #

############################################################

#print "Month is $month and the day is $day <p\/>";

#if ($month == 1 and $day >= 29) {

#print $q->redirect("http://some.place.org/");

#print "$spacer <div align=center>Sorry there are not $day in the $yr </div><p\/>";

#}

#####################################

# Read file to check for duplicates #

#####################################

open(JOE, "<Files/$employee.txt")or die "No can!";

@data = <JOE>;

chomp (@data);

close (JOE);

$lines =scalar(@data);

$lines =$lines/5;

#####################################

# Check for duplicates #

#####################################

#print "Lines is $lines <p\/>";

#print "FORM Certification is $certification<p\/>";

for ($i =0; $i <= $lines; $i++) {

#print "<HR>";

#print "This is Loop $i<p\/>";

for ($ii =0; $ii <= 5; $ii++) {

$x_certification =shift(@data);

$x_extra_email =shift(@data);

$x_month =shift(@data);

$x_day =shift(@data);

$x_year =shift(@data);

$x_mo_yr =shift(@data);

#print "Data is: $x_certification $x_extra_email $x_month $x_day, $x_year $x_mo_yr;<p\/>";

if ($x_certification eq $certification) {

#print "MATCH!<p\/>";

print "$spacer<div align=center> Sorry $employee already has a $certification certification. </div><p\/>";

print '<div align="center"><table width="120" border="1" cellspacing="2" cellpadding="0"><tr><td align="center">To go Back</td></tr><tr><td align="center"><a href="http://www.hawaiicivilmarriage.com/FFD/index.html">Click Here</a></td></tr></table><p></p></div>';

exit;

}

}

}

#####################################

# Calculate 3 months #

#####################################

if ($mo == 1) {

$mo = 10;

$yr =$yr-1;

}

elsif ($mo == 2) {

$mo =11;

$yr =$yr-1;

}

elsif ($mo == 3) {

$mo =12;

$yr =$yr-1;

}

elsif ($mo == 4) {

$mo =1;

}

elsif ($mo == 5) {

$mo =2;

}

elsif ($mo == 6) {

$mo =3;

}

elsif ($mo == 7) {

$mo = 4;

}

elsif ($mo == 8) {

$mo =5;

}

elsif ($mo == 9) {

$mo =6;

}

elsif ($mo == 10) {

$mo =7;

}

elsif ($mo == 11) {

$mo =8;

}

elsif ($mo == 12) {

$mo =9;

}

#print "3 months prior to expiration is $mo, $yr.<p\/>";

#####################################

# Write File #

#####################################

$mo_yr =join (' ', $mo,$yr);

$date = scalar(localtime(time));

$number =$mo;

#print "The month and year variable is $mo_yr<p\/>";

open(JOE, ">>Files/$employee.txt");

print JOE "$certification\n";

print JOE "$extra_email\n";

print JOE "$month\n";

print JOE "$days\n";

print JOE "$year\n";

print JOE "$mo_yr\n";

close (JOE);

print '<div align="center"><table width="120" border="1" cellspacing="2" cellpadding="0"><tr><td align="center">To go Back</td></tr><tr><td align="center"><a href="http://www.hawaiicivilmarriage.com/FFD/index.html">Click Here</a></td></tr></table><p></p></div>';

print '</body>';

#####################################

print "$spacer<div align=center><B>$employee</B> has succesfully updated his record on $date</div><p\/>";

$mo = $mon[$number-1];

print "<div align=center>You will be e-mailed in $mo, $yr as a reminder to renew your certification.</div><p\/>";

exit;

Back to Computer Directory

Back to Main Page