Solved

CGI does not work properly

Posted on 1997-08-19
4
166 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now