I checked the %ENV with the diagnostic script it shows REMOTE_USER is there and has the correct value. However it still does not capture the value for my script. What is wrong. Again if I set $user equal to a value it works if I try to capture the remote_user with either the %ENV or the CGI function it will not work either way.
#!/usr/bin/perl -w
#Volunteer.pl - Insert Volunteers into database
use strict;
use DBI;
use CGI;
my $query = CGI::new();
my ($dbh, $sth, $sql, $name, $date, $sub_parent, $col);
my @volunteer_date = $query->param("Volunteer");
my $parent = $query->param("Parent");
#my $user = $query->REMOTE_USER();
my $user = $ENV{"REMOTE_USER"};
#my $user = "<Player Name>";
#my $name = undef;
#my $parent = "Father";
#my @volunteer_date = ("2002-01-18");
print $query->header(),
$query->start_html (-title=>'Volunteer List Form',
-link=>'#FFFFFF',
-vlink=>'99FF99',
-alink=>'black',
-style=>{'-src'=>'/CSS/stylesheet.css'});
database connection goes here.
# store subparent for each parent
my %parent_hash = ( 'Father' => 'Mother',
'Mother' => 'Father' );
if ( @volunteer_date ){
if (exists $parent_hash{$parent}) {
my $sub_parent = $parent_hash{$parent};
for $col ( $parent, $sub_parent ) {
$sql = "select $col from Roster where User=?";
$sth = $dbh->selectcol_arrayref( $sql, undef, $user );
print $query->h1({-align=>'center'},"$sub_parent, $parent, $user");
if ( @$sth && $sth->[0] ) { # any rows returned?
$name = $sth->[0]; # take first one
#last;
}
}
}
print $query->h1({-align=>'center'},"THANK YOU FOR SIGNING UP $name");
foreach $date ( @volunteer_date ) {
$sql = "select distinct Volunteer from Volunteer where Volunte
+er =? and Date =?";
my $sth = $dbh->selectcol_arrayref( $sql, undef, $name, $date
+);
#Verify the parent is not signed up.
if( @$sth ) {
print $query->h1({-align=>'center'}, "You are already sig
+ned up for this date: $date");
last;
}
}
}
print $query->h1({-align=>'center'},"THANK YOU FOR SIGNING UP $name");
foreach $date ( @volunteer_date ) {
$sql = "select distinct Volunteer from Volunteer where Volunte
+er =? and Date =?";
my $sth = $dbh->selectcol_arrayref( $sql, undef, $name, $date
+);
#Verify the parent is not signed up.
if( @$sth ) {
print $query->h1({-align=>'center'}, "You are already sig
+ned up for this date: $date");
last;
} #end if statement
#process the information and update the schedule.
else{
my $sql = "select max(Number) from Volunteer where Date =? and
+ Volunteer = 'TBD'";
my $number = $dbh->selectcol_arrayref($sql, undef, $date);
$sql = "update Volunteer set Volunteer = '$name' WHERE Date =
+'$date' and Number = $number->[0]";
$sth = $dbh->prepare($sql) || die "prepare: $$sql: $DBI::errst
+r";
$sth->execute || die "execute: $sql->[0]: $DBI::errstr";
print $query->h1({-align=>'center'}, "You signed up for this d
+ate $date");
$sth->finish ();
$dbh->disconnect ();
} #end else statement
} #end foreach loop
} #end if volunteer_date check
else{
print $query->h1({-align=>'center'}, "You did not select a dat
+e");
} #end else volunteer_date check
# print $query->end_html;
print $query->h2({-align=>'center'},
$query->a({href=>'../UnSignup.pl'}, 'UNDO SIGNUP'), '&nb
+sp',
$query->a({href=>'../BobSchedule.pl'}, 'BOBS SCHEDULE'),
+ ' ',);
$query->end_html;
print $query->h3({-align=>'center'},
$query->a({href=>'Volunteer.pl'}, 'BACK'), ' ',);
$query->end_html;
|