Solved

CGI does not work properly

Posted on 1997-08-19
4
168 Views
Last Modified: 2013-12-25
Hi, I am very new to Perl and HTML. I am currently creating a guestbook using html. If the user clicked on the submit button, I will called my perl file to check whether they have entered all the necessary fields.

If the form is not complete, I will then display another redopage html informing them.

But my redopage html does not get shown up. Is it possible for the perl to open up another html???

Below is my perl file which only consists of the calling part, but still the html does not get showed up. Did I miss out any library??? I am actually running it in Windows NT.

/*** my *.pl file ***/

use CGI;

$redopage="/olticket/jonr&d/redopage.html";
$redo;

sub redo
{
      print (REDOPAGE $redopage);
      while (<REDOPAGE>)
      {
           print $_;
      }
      Close(REDOPAGE);
      exit;
}
Could anyone please help.

Thank you.

Regards
Yann Ming
0
Comment
Question by:ymlew
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
icd earned 100 total points
ID: 1829729
The problem is that you are not opening the file. Try:-

sub redo
{
open (REDOPAGE $redopage);
while (<REDOPAGE>)
   {
   print $_;
   }
close(REDOPAGE);
}

Note that I changes 'print' to 'open'. I removed the 'exit' from the procedure. I changed 'Close' to 'close' (perl is case sensitive).

I think I found all the errors... but if it still does not work get back to me before grading the answer.

0
 

Author Comment

by:ymlew
ID: 1829730
I have tried it but it still does not work. I actually put a print statement after calling the redo sub-routine. My message got printed out, but the html just does not got showed up.

Did I miss out some library which I should have included???

Regards
Yann Ming
0
 
LVL 7

Expert Comment

by:faster
ID: 1829731
Before you print out the contents of the html, you should print the following: "Content-type: text/html\n\n".  Did you include that?
0
 
LVL 5

Expert Comment

by:icd
ID: 1829732
faster is quite right is stating that the Content-type has to be output but this would not explain why the file is not output.

The next most likely explaination is that the path to the file is wrong. The path you gave seems to be one relative to your web page root directory. This will not be the path if you (for example) telnet into the site. Assuming that your script is in the cgi-bin directory try changing the path to a relative path name, e.g.

$redopage="../olticket/jonr&d/redopage.html";

(or whatever is appropriate).

You can also put some diagnostics into your file. e.g.

open (REDOPAGE $redopage) || die "<HTML><HEAD><BODY>Cannot open file $redopage reason $!</BODY></HTML>\n";

(this should all be on one line).


0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question