Solved

CGI does not work properly

Posted on 1997-08-19
4
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

719 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