I thought this script was working. I absolutely cannot get IIS to fully and completely work on my home comp. After making a special trip to school to test this thing out, it ends up that it's only displaying the last data entered instead of the averages, totals, etc. This thing is due for class tomorrow. I've changed around a few things here & there and it's still working no better (no worse either, far as that goes). Anyone have a clue what I need to do? In case it's needed, I'll post both the .html & the .cgi.
#!C:/Perl/bin/perl.exe
#Football Stats
print "Content-type: text/html\n\n";
use CGI qw(:standard);
use strict;
use SDBM_File;
use Fcntl;
##########variable declarations and input assignments#############################
my ($yourTmScore, $otherTmScore, $passYrdPGame, $rushYrdPGame, $homeCount, $awayCount, $turnovAllowedPGame, $tds, $tdsAllowed, $sacksTotal, $sacksPerGameAvg, $sacksAllowedTotal, $sacksAllowedAvg, $turnovForcedTotal, $turnovForcedAvg, $turnovAllowedTotal, $turnovAllowedAvg, $wins, $losses, $winPercent, $winPercentHome, $winPercentAway, $winLose, $tieGames, $tdsAllowedTotal,
$rushYrdTotal, $passYrdTotal, $tdsTotal, $tdsAvg, $tdsAllowedAvg, $tdsAvg, $rushYrdAvg, $yourTmScoreTotal, $otherTmScoreTotal,
$otherTmScoreAvg, $yourTmScoreAvg, $passYrdAvg);
my $weekNum = param('weekNum');
my $whereAt = param('gamePlayed');
my $homeCounter = 0;
my $awayCounter = 0;
my $yourTmScore = param('yourTmScore');
my $otherTmScore = param('otherTmScore');
my $passYrdPGame = param('passYrdPGame');
my $rushYrdPGame = param('rushYrdPGame');
my $sacks = param('sacks');
my $sacksAllowed = param('sacksAllowed');
my $turnovForcedPerGame = param('turnovForcedPerGame');
my $turnovAllowedPGame = param('turnovAllowedPGame');
my $tds = param('tds');
my $tdsTotal = $tds + $tdsTotal;
my $tdsAllowed = param('tdsAllowed');
$tdsAllowedTotal = $tdsAllowed + $tdsAllowedTotal;
$rushYrdTotal = $rushYrdPGame + $rushYrdTotal;
$passYrdTotal = $passYrdPGame + $passYrdTotal;
$yourTmScoreTotal = $yourTmScore + $yourTmScoreTotal;
$otherTmScoreTotal = $otherTmScore + $otherTmScoreTotal;
$sacksTotal = $sacks + $sacksTotal;
$sacksAllowedTotal = $sacksAllowed + $sacksAllowedTotal;
$turnovForcedTotal = $turnovForcedTotal + $turnovForcedPerGame;
$turnovAllowedTotal = $turnovAllowedTotal + $turnovAllowedPGame;
########save to file#######################################
open(OUTFILE, ">>","nflStats.txt")
or die "Error opening nflStats.txt $!, stopped";
print OUTFILE join(':::',
$weekNum, $whereAt, $yourTmScore, $otherTmScore, $passYrdPGame, $rushYrdPGame, $sacks, $sacksAllowed, $turnovForcedPerGame,
$turnovAllowedPGame, $tds, $tdsAllowed), "\n";
close(OUTFILE);
####################### do calculations (in while loop) ##################
open(INFILE, "<", "nflStats.txt");
my $ctr = 0;
while(<INFILE>) {
$ctr = $ctr + 1;
my ($weekNum, $whereAt, $yourTmScore, $otherTmScore, $passYrdPGame, $rushYrdPGame, $sacks, $sacksAllowed, $turnovForcedPerGame,
$turnovAllowedPGame, $tds, $tdsAllowed) = split(':::');
my $tdsAvg = $tdsAvg/$ctr;
my $tdsAllowedAvg = $tdsAllowedAvg/$ctr;
my $rushYrdAvg = $rushYrdTotal/$ctr;
my $passYrdAvg = $passYrdTotal/$ctr;
my $yourTmScoreAvg = $yourTmScoreTotal/$ctr;
my $otherTmScoreAvg = $otherTmScoreTotal/$ctr;
my $sacksPerGameAvg = $sacksTotal/$ctr;
my $sacksAllowedAvg = $sacksAllowedTotal/$ctr;
my $turnovForcedAvg = $turnovForcedTotal/$ctr;
my $turnovAllowedAvg = $turnovAllowedTotal/$ctr;
if ($whereAt eq 'Home')
{
$homeCounter = $homeCounter + 1;
}
elsif ($whereAt eq 'Away')
{
$awayCounter = $awayCounter + 1;
}
if ($yourTmScore > $otherTmScore)
{
$wins = $wins + 1;
}
else
{
$losses = $losses + 1;
}
if ($yourTmScore == $otherTmScore)
{
$tieGames = $tieGames + 1;
}
}
close INFILE;
######################### end while loop #########################
################ generate page #########################
print <<endHtml;
<html>
<head><title>Current Cowboys Statistics</title>
<script type="text/javascript">
window.defaultStatus = "Results so far...";
</script></head>
<body link="navy" vlink="navy" alink="navy">
<font size="3">
<font size="6"><div align="center">Weeks played: $weekNum</div></font><br /><br />
<hr width="90%" color="#CCCCCC" size="4"><br /><br />
<p>
<table width="750" border="1" bgcolor="navy" align="center">
<tr>
<td colspan="4" bgcolor="white"><font size="4" color="navy"><div align="center"><b>SCORING</b></div></font></td>
</tr>
<tr><td colspan="2"><font size="3" color="white"><div align="center"><b>OWN</b></div></font></td><td colspan="2"><font size="3" color="white"><div align="center"><b>OPPONENT</b></div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">Points Scored Total</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Points Averaged per Game</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Points Allowed Total</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Points Allowed Avg. per Game</div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">$yourTmScoreTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$yourTmScoreAvg</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$otherTmScoreTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$otherTmScoreAvg</div></font></td>
</tr>
</table>
</p><br />
<table width="85%" border="0" align="center">
<tr>
<td width="50%" align="center">
<p>
<table width="300" border="1" bgcolor="navy">
<tr>
<td colspan="2" bgcolor="white"><b><font size="4" color="navy"><div align="center">GAME LOCATIONS</div></font></b></td>
</tr>
<tr>
<td width="50%"><div align="center"><font size="3" color="white">Home:</font></div></td>
<td width="50%"><div align="center"><font size="3" color="white">Away:</font></div></td>
</tr>
<tr>
<td width="50%"><div align="center"><font size="3" color="white">$homeCounter</font></div></td>
<td width="50%"><div align="center"><font size="3" color="white">$awayCounter</font></div></td>
</tr>
</table>
</p>
</td>
<td width="50%" align="center">
<p>
<table width="300" border="1" bgcolor="navy">
<tr>
<td colspan="3" bgcolor="white"><font size="4" color="navy"><div align="center"><b>WINS & LOSSES</b></div></font></td>
</tr>
<tr>
<td width="33%"><div align="center"><font size="3" color="white">Wins</font></td>
<td width="33%"><div align="center"><font size="3" color="white">Losses</font></td>
<td width="33%"><div align="center"><font size="3" color="white">Ties</font></td>
</tr>
<tr>
<td width="33%"><div align="center"><font size="3" color="white">$wins</font></td>
<td width="33%"><div align="center"><font size="3" color="white">$losses</font></td>
<td width="33%"><div align="center"><font size="3" color="white">$tieGames</font></td>
</tr>
</table>
</p>
</td>
</tr>
</table><br />
<p>
<table width="750" border="1" bgcolor="navy" align="center">
<tr>
<td colspan="4"bgcolor="white"><font size="4" color="navy"><div align="center"><b>TOUCHDOWNS</b></div></font></td>
</tr>
<tr><td colspan="2"><font size="3" color="white"><div align="center"><b>TD's MADE</b></div></font></td><td colspan="2"><font size="3" color="white"><div align="center"><b>TD's ALLOWED</b></div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">Total Touchdowns</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">TD's Avg. per Game</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Total Touchdowns Allowed</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">TD's Allowed Avg. per Game</div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">$tdsTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$tdsAvg</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$tdsAllowedTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$tdsAllowedAvg</div></font></td>
</tr>
</table>
</p><br />
<p>
<table width="750" border="1" bgcolor="navy" align="center">
<tr>
<td colspan="4" bgcolor="white"><font size="4" color="navy"><div align="center"><b>OFFENSIVE PERFORMANCE</b></div></font></td>
</tr>
<tr><td colspan="2"><font size="3" color="white"><div align="center"><b>RUSHING YARDS</b></div></font></td><td colspan="2"><font size="3" color="white"><div align="center"><b>PASSING YARDS</b></div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">Total Rushing Yards</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Rushing Yards Avg. per Game</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Total Passing Yards</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Passing Yards Avg. per Game</div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">$rushYrdTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$rushYrdAvg</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$passYrdTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$passYrdAvg</div></font></td>
</tr>
</table>
</p><br />
<p>
<table width="750" border="1" bgcolor="navy" align="center">
<tr>
<td colspan="4" bgcolor="white"><font size="4" color="navy"><div align="center"><b>SACKS</b></div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">Total Sacks Made</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Sacks Made Avg. per Game</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Total Sacks Allowed</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Sacks Allowed Avg. per Game</div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">$sacksTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$sacksPerGameAvg</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$sacksAllowedTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$sacksAllowedAvg</div></font></td>
</tr>
</table>
</p><br />
<p>
<table width="750" border="1" bgcolor="navy" align="center">
<tr>
<td colspan="4" bgcolor="white"><font size="4" color="navy"><div align="center"><b>TURNOVERS</b></div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">Total Turnovers Made</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Turnovers Avg. per Game</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Total Turnovers Allowed</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">Turnovers Allowed Avg. per Game</div></font></td>
</tr>
<tr>
<td width="25%"><font size="3" color="white"><div align="center">$turnovForcedTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$turnovForcedAvg</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$turnovAllowedTotal</div></font></td>
<td width="25%"><font size="3" color="white"><div align="center">$turnovAllowedAvg</div></font></td>
</tr>
</table>
</p><br />
<p><font size="5" face="Arial Black"><a href="" onclick="self.close();">Close Window</a><br /><br />
<a href="C:\Inetpub\wwwroot\public_html\Perl Semester Project\nflStats.html">Enter more stats</a></font></p>
</font>
</body></html>
endHtml
<!nflStats.html>
<html>
<head><title>Stats For the Dallas Cowboys</title>
<script type="text/javascript">
window.defaultStatus = "Keep up with the Cowboys this year!";
function confirmSubmit() {
var submitForm = window.confirm("Make sure that all of the fields have been filled in completely.");
if (submitForm == true)
return true;
return false;
}
function confirmReset() {
var resetForm = window.confirm("Are you sure you want to clear all of the above contents?");
if (resetForm == true)
return true;
return false;
}
function showPics(linkTarget) {
picWindow = window.open(linkTarget, "showPics", "toolbar=no,menubar=no,location=no,scrollbars=no,resiable=no,width=550,height=570");
}
</script></head>
<body background="nflShield.bmp">
<table width="55%" border="0" align="center" cellpadding="5">
<tr>
<td bgcolor="#000066"><div align="center"><font size="5" color="#FFFFFF">Use the fields below to enter weekly stats<br />for the Dallas Cowboys.</font></div></td>
</tr>
</table>
<form action="http://localhost/cgi-bin/nflStats.cgi" method="post" onsubmit="return confirmSubmit();" onreset="return confirmReset();">
<font size="4" face="Arial">
<table width="97%" border="0" align="center">
<tr><td colspan="4"><hr color="#CCCCCC" /></td></tr>
<tr>
<td width="25%" valign="top" align="left">
<p>Week of the game:
<select name="weekNum">
<option></option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
</select></p>
</td>
<td width="25%" align="right" valign="top">
<p>Played at:<br />
Home<input type="radio" name="gamePlayed" value="Home"> Away<input type="radio" name="gamePlayed" value="Away"></p>
</td>
<td width="25%" align="right" valign="top">
<p>Touchdowns: <input type="text" name="tds" size="3" maxlength="2"></p>
</td>
<td width="25%" align="right" valign="top">
<p>Touchdowns Allowed <input type="text" name="tdsAllowed" size="3" maxlength="2"></p>
</td>
</tr>
<tr><td colspan="4"><hr color="#CCCCCC" /></td></tr>
<tr>
<td width="25%" valign="top" align="left">
<p>Cowboys' Score: <input type="text" name="yourTmScore" size="3" maxlength="3"></p>
</td>
<td width="25%" align="right">
<p>Opponent's Score: <input type="text" name="otherTmScore" size="3" maxleghth="3"></p>
</td>
<td width="25%" align="right" valign="top">
<p>Passing Yards: <input type="text" name="passYrdPGame" size="4" maxlength="3"></p>
</td>
<td width="25%" valign="top" align="right">
<p>Rushing Yards: <input type="text" name="rushYrdPGame" size="4" maxlength="3"></p>
</td>
</tr>
<tr><td colspan="4"><hr color="#CCCCCC" /></td></tr>
<tr>
<td width="25%" align="left" valign="top">
Sacks Made: <input type="text" name="sacks" size="3" maxlength="2">
</td>
<td width="25%" align="right" valign="top">
Sacks Allowed: <input type="text" name="sacksAllowed" size="3" maxlength="2">
</td>
<td width="25%" valign="top" align="right">
Turn Overs Forced: <input type="text" name="turnovForcedPerGame" size="3" maxlength="2">
</td>
<td width="25%" align="right" valign="top">
Turn Overs Allowed: <input type="text" name="turnovAllowedPGame" size="3" maxlength="2">
</td>
</tr>
</table>
</font>
<div align="right"><input type="submit" value="Submit Stats">
<input type="reset" value="Reset Stats"></div>
</form><br />
<table width="85%" align="center" border="0">
<tr>
<td width="50% align="left" valign="top">
<script type="text/javascript">
// Create arrays to contain all the values
// for links and image locations
var link = new Array;
var image = new Array;
link[1] = 'http://www.dallascowboys.com';
link[2] = "http://www.nfl.com";
link[3] = "http://www.nflplayers.com";
link[4] = "http://www.nfl.com/probowl";
link[5] = "http://www.superbowl.com";
image[1] = "bannerCowboysDotCom.jpg";
image[2] = "bannerNFLDotCom.jpg";
image[3] = "bannerNFLPlayers.jpg";
image[4] = "bannerProBowl.jpg";
image[5] = "bannerSuperBowl.jpg";
// Create a random number between 1 and last number
random_num = (Math.round((Math.random()*4)+1));
// Write a link and images with random array
document.write('<a href="' + link[random_num] + '" target="_blank">');
document.write('<img src="' + image[random_num] + '" border="0"></a>');
</script>
</td>
<td width="50%" align="right" valign="top">
<a href="cpic1.html" onmouseover="self.status='View Cowboys pictures here';return true" onclick="showPics('cpic1.html');return false"><img src="cowboyPics.jpg" border="0"></a>
</td>
</tr>
</table>
</body>
</html>