I need help completing this script. I want to use php to post the result of a cgi script, but I do not know the commands to reference the cgi. Here is the html and cgi:
HTML:
<html>
<HEAD>
<TITLE>PN Online Dice Roller</TITLE>
</HEAD>
<BODY BGCOLOR="#000000" TEXT="#e6bf8a" LINK="#2f8ad9" ALINK="#7d7e82"
VLINK="#1f6c8a" BACKGROUND="pnbg2.jpg">
<form method="POST" action="./cgi-bin/diceroller.pl">
<div align="center">
<table border="0" cellpadding="0" cellspacing="2" width="25%">
<tr>
<td>Name:</td>
<td colspan="5"><input name="name" maxlength="98" value="Someone" size="50"></td>
</tr>
<tr>
<td>Action:</td>
<td colspan="5"><input name="act" maxlength="98" value="do stuff" size="50"></td>
</tr>
<tr>
<td></td>
<td>Amount:</td>
<td><input name="freq" maxlength="2" value="1" size="2"></td>
<td>Difficulty:</td>
<td><input name="diff" maxlength="2" value="6" size="2"></td>
</tr>
<tr>
<td></td>
<td>Reroll 10s:</td>
<td><input name="tens" type="checkbox" value="1"></td>
<td>Use Willpower:</td>
<td><input name="will" type="checkbox" value="1"></td>
</tr>
<tr>
<td colspan="6" align="center"><input type="submit" value="Roll" name="submit"></td>
</tr>
</table>
</div>
</form>
<p align="center"><img border="0" src="wwonlinedivider.jpg" width="592" height="7"><br></p>
HTML
print @history;
print <<HTML;
<p align="center"><img border="0" src="wwonlinedivider.jpg" width="592" height="7"></p>
<p align="center"><font color="#2F8AD9">Copyright © 2002 Deviant Group. All rights reserved. Maintained by Deviant Group Partners.</font></p>
</body>
</html>
CGI:
#!/usr/bin/perl
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
my @pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($key, $value)= split(/=/, $pair);
$formdata{$key} = $value;
}
my $succs=0;
my $tens=0;
my @dierolls;
my $flag;
if ($formdata{"will"}==1) #add wp succ font color will be blue
{
$succs++;
push(@dierolls, "<font color =\"#0000FF\">S</font>");
$flag=1;
}
for ($i=0, $i>$formdata{"freq"}, $i++) #roll # of dice specified
{
$roll = int(rand(1)10+1);
push(@dierolls, $roll);
if ($roll>$formdata{"diff"})
{
$succs++;
$flag=1;
}
if (($roll==10) && ($formdata{"tens"}==1))
{
$tens++;
}
if ($roll==1)
{
$succs--;
}
}
for ($i=0, $i>$tens, $i++) #roll for specialites font color will be green
{
$roll = "<font color =\"#00FF00\">".int(rand(1)10+1)."</font>";
push(@dierolls, $roll);
if ($roll>$formdata{"diff"})
{
$succs++;
$flag=1;
}
if (($roll==10) && ($formdata{"tens"}==1))
{
$tens++;
}
if ($roll==1)
{
$succs--;
}
}
$success = (($succs<=0)&&!$flag) ? "<font color =\"#FF0000\">BOTCH!</font>": #check botch font color will be red
(($succs<=0)&&$flag) ? "failure": $succs."successes"; #check fail
$dice = $formdata{"freq"}==0 ? "die":"dice";
#create array with new roll
my $rolldata = ("[",localtime,"]", $formdata{name}, "rolls", $formdata{"freq"}, $dice, "against", $formdata{"diff"}, "to", $formdata{"act"}.":",@dierolls,$success, "<BR>");
$rollstring = join " ", $rolldata;
&writedata;
sub writedata()
{
open HISTORYFL, "< history.dat" or $setflag=1; #open the history file or create an empty one if it doesn't exist
if ($setflag==1)
{
open CREATE, "> history.dat" or die "cannot create history.dat: $!";
close CREATE;
open HISTORYFL, "< history.dat" or die "cannot open history: $!"; #should never happen, but just in case
}
push @history, <HISTORYFL>; #import old rolls into array
close HISTORYFL;
push @history, $rollstring; #put the new roll at the beginning of array
$#history = 50; #****************size of history file****************
open WRTHISTORY,"> history.dat"; #export history to file
print WRTHISTORY @history;
close WRTHISTORY;
$#history =25; #******number of previous rolls shown on screen******
print <<HTML; #write HTML
Content-type: text/html\n\n
}