[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Processing HTML Data With a CGI Script

I'm trying to pass radio button data from an HTML page through a CGI script to interrogate the data and set a variable. I'm receiving the following error message:

    CGI Error

    The specified CGI application misbehaved by not returning a        
    complete set of
    HTTP headers. The headers it did return are:

    syntax error at d:\inetpub\www0244\cgi-bin\invoice2.cgi line 100,  
    near "if"
    Execution of d:\inetpub\www0244\cgi-bin\invoice2.cgi aborted due to
    compilation

The script code that was added to read the HTML radio button data is:

sub GetCart {

&ReadParse(*input);

if ($input{'r1'} eq "S1") {
        $price = 59;
        }
else
        if ($input{'r1'} eq "S2") {
                $price = 149;
                }
        else {
                $price = 399}
        }

The HTML statement is:

<form action="http://209.12.95.44/cgi-bin/invoice.cgi"
method="POST">
    <input type="hidden" name="q1" value="1"><input type="hidden"
    name="q2" value="1"><input type="hidden" name="q3" value="1"><p
    align="left"><font color="#FF0000" size="3"><em><b>I want to
    purchase the following Subscription from TRC!</b></em></font></p>
    <p align="left"><font size="3"><input type="radio" name="r1"
    value="S1"><strong>One Month @ only $59</strong><br>
    <input type="radio" name="r1" value="S2"><strong>Three months
    @ only $149</strong><br>
    <input type="radio" name="r1" value="S3"><strong>One Year @
    only $399</strong><br>
    </font></p>
    <p><font size="3"><input type="submit" name="Submit"
    value="Send">- Select to Send the order
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
    type="reset" value="Clear">- Select to Clear the order</font></p>
</form>

I don't see the syntax error.  Do you?  Can something else be wrong?
0
trcenter
Asked:
trcenter
1 Solution
 
fasterCommented:
The syntax is wrong, should add a {} around the "else" like this:

sub GetCart {
  &ReadParse(*input);
  if ($input{'r1'} eq "S1") {
    $price = 59;
  } else  {
    if ($input{'r1'} eq "S2") {
      $price = 149;
    } else {
      $price = 399;
    }
  }
}
 
0
 
trcenterAuthor Commented:
Thank you
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now