Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI error

Status
Not open for further replies.

EchoCola

Programmer
Apr 13, 2004
48
US
Hey guys, I'm getting an error on this CGI script, I can't seem to find it.
here is the html and the script
Code:
<form name="form1" method="post" action="reviews.cgi">
  <p align="center"><b><font color="#5E00BB" size="6">&nbsp;&nbsp;&nbsp;&nbsp;</font><font size="6"><span class="style5">Rate -A- Resort </span></font></b></p>
  <p align="center"> <img src="../palmtree.jpg" width="112" height="147"></p>

  <table width="75%" border="0" bordercolor="#000000">
    <tr> 
      <td width="44%" height="33" valign="top"> 
        <div align="right" class="style6">Resort</div>

      </td>
      <td width="56%" valign="top"> &nbsp; 
        <input name="resortname" type="text" id="resortname" size="40">
      </td>
    </tr>

    <tr> 
      <td width="44%" height="97" valign="top"> 
        <div align="right" class="style6">Your Review</div>
      </td>

      <td width="56%" height="97" valign="top"> &nbsp; 
        <textarea name="review" cols="40"></textarea>
      </td>
    </tr>
    <tr> 
      <td width="44%" height="47" valign="top"> 
        <div align="right" class="style6">Time Stayed</div>

      </td>
      <td width="56%" valign="top"> &nbsp; 
        <input name="time" type="text" id="time">

      </td>
    </tr>
    <tr> 
      <td width="44%" height="41" valign="top"> 
        <div align="right" class="style6">Your Name</div>
      </td>

      <td width="56%" valign="top"> &nbsp; 
        <input name="yourname" type="text" size="40">
      </td>

    </tr>
    <tr> 
      <td width="44%" height="40" valign="top"> 
        <div align="right" class="style6"> Rating</div>
      </td>

      <td width="56%" valign="top"> &nbsp; 
        &nbsp;&nbsp; 
        <input type="radio" name="rate" value="1">
        1 
        <input type="radio" name="rate" value="2">

        2 
        <input type="radio" name="rate" value="3">
        3 
        <input type="radio" name="rate" value="4">
        4 
        <input type="radio" name="rate" value="5">

      5 </td>
    </tr>
    <tr> 
      <td width="44%" height="41" valign="top">

        <div align="right" class="style6">Anonymous</div>
      </td>
      <td width="56%" valign="top"> &nbsp; 
        <input type="checkbox" name="anonymous" value="1">

      </td>
    </tr>
    <tr> 
      <td colspan="2"> 
        <div align="center"> 
          <input type="submit" name="Submit" value="Submit">
And here is the script:
Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
use CGI qw/:standard/;

$resortname=param('resortname');
$review=param('review');
$time=param('time');
$rate=param('rate');
$anonymous=param('anonymous');

if($anonymous != 1)
{
	$yourname=param('yourname');
}
else
{
	$yourname=anonymous;
}


open(OUTF,">>reviews.txt");
print OUTF "\n<b>$yourname</b>stayed for <b>$age</b> and rated the resort <b>$moviename</b> with a <b>";

for ($i=1;$i<=$rate;$i++){
print OUTF "<img src=\"images/star.gif\"> ";
}

print OUTF "$rate</b> star rating --<br>Review:<br>  <b>$review</b>";
close(OUTF);


open(COUNTF,"numvisiotrs.txt");
$counter=<COUNTF>;
close(COUNTF);

chop($counter);
$counter++;

open(COUNTF,">numvisiotrs.txt");
print COUNTF $counter,"\n";
close(COUNTF);


if($counter eq 5)
{
	print "<html><head><title>Review Output</title></head><body>";
	print "<h2>Congratulations ! You are the visitor number 5 !</h2>";
	print "</body>";
}

print "<<na<html><head><title>Review Output</title></head><body>Thank you for your time. <p>Your review was successfully saved as number $counter</p><p> Please click on the following link to see all reviews: <a href="[URL unfurl="true"]http://matrix.csis.pace.edu/~panavian/cgi-bin/showreviews.cgi">see[/URL] all reviews</a>.</body>na";
 
Code:
print "<<na"
<html><head><title>Review Output</title></head><body>Thank you for your time. <p>Your review was successfully saved as number $counter</p><p> Please click on the following link to see all reviews: <a href="[URL unfurl="true"]http://matrix.csis.pace.edu/~panavian/cgi-bin/showreviews.cgi">see[/URL] all reviews</a>.</body>
na;
or
Code:
print "<html><head><title>Review Output</title></head><body>Thank you for your time. <p>Your review was successfully saved as number $counter</p><p> Please click on the following link to see all reviews: <a href=\"[URL unfurl="true"]http://matrix.csis.pace.edu/~panavian/cgi-bin/showreviews.cgi\">see[/URL] all reviews</a>.</body>";

You're not closing your html tag though
</html>

To syntax check your script, on the command line
Code:
perl -c script.pl



It's important in life to always strike a happy medium, so if you see someone with a crystal ball, and a smile on their face ...
 
I believe it should be like this:

Code:
print <<na;
<html><head><title>Review Output</title></head><body>Thank you for your time. <p>Your review was successfully saved as number $counter</p><p> Please click on the following link to see all reviews: <a href="[URL unfurl="true"]http://matrix.csis.pace.edu/~panavian/cgi-bin/showreviews.cgi">see[/URL] all reviews</a>.</body></html>
na

You need to have at least one blank line after the closing na

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top