Web Analytics Made Easy -
StatCounter Have problem working between cgi and html - CodingForum

Announcement

Collapse
No announcement yet.

Have problem working between cgi and html

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Have problem working between cgi and html

    Hi folks,

    I am new in cgi web programming here. I have a problem between html and cgi. Basically, i am trying to write a calculator in cgi and then put it in web server. When user go to my site will see the html page below:


    html code
    Code:
    <HTML>
    <HEAD>
      <TITLE></TITLE>
    </HEAD>
    
    <BODY>
    
    <FORM ACTION="default.cgi" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">
    <H2>Evaluate Reverse Polish Expression</H2>
    <P>
    <TABLE BORDER="0" WIDTH="490">
      <TR>
        <TD WIDTH="71%">
          <P ALIGN="CENTER">Enter a reverse polish expression to evaluate:
        </TD>
        <TD WIDTH="15%">&nbsp;</TD>
        <TD WIDTH="14%">&nbsp;</TD>
      </TR>
      <TR>
        <TD COLSPAN="3">
          <CENTER>
          <P><INPUT TYPE="TEXT" NAME="Field" SIZE="50">
    </CENTER>
        </TD>
      </TR>
      <TR>
        <TD WIDTH="71%">&nbsp;</TD>
        <TD WIDTH="15%">
          <CENTER>
          <P><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
    </CENTER>
        </TD>
        <TD WIDTH="14%">
          <CENTER>
          <P><INPUT TYPE="RESET" NAME="Reset" VALUE="Reset">
    </CENTER>
        </TD>
      </TR>
      <TR>
        <TD COLSPAN="3">
          <P ALIGN="CENTER">The value of the expression 1 2 3 + * is 5
        </TD>
      </TR>
    </TABLE>
    
    </FORM>
    
    </BODY>
    
    </HTML>
    And they will put the function in the text area then click submit. And then that information will be transfer to my cgi script which will calculate and then put it on same html page. Can anyone tell me how to do that ?, i got the cgi working now, but still not figure out how to make it work with those html code above. Hope my explaination make sense. thanks

  • #2
    Can you show us your perl script?

    Comment


    • #3
      this:

      <FORM ACTION="default.cgi"

      should maybe be:

      <FORM ACTION="cgi-bin/default.cgi"

      if you have to run your scripts in the cgi-bin.

      If you want the output displayed back in the same html page that will probably be a bad idea. Your script would have to open the html document and write the output into the html document, save it, then redirect the browser to the html page. But the next time a person looks at that html page they will see the outputs from the previous times the script was run. Might be best to just have the script just generate an on the fly html page that never gets saved to disk and is only viewed while the person has their browser window opened.

      Comment


      • #4
        If you just want the output to display in the same page you might want to use javascript instead of a cgi backend script. javascript is good for what you want to do: display output in the same window.

        Comment


        • #5
          This looks like a homework assignment.

          Let us know if it is ...

          We don't do homework, but if you show us the script and ask
          a specific question, we might be able to help out there.

          Comment

          Working...
          X