Solved

Document contains no data

Posted on 1997-11-04
2
169 Views
Last Modified: 2013-12-25
Please help me,
I wrote a cgi:

#!/usr/bin/perl

print "Content-type: text/html\n\n";

#full path
$file="/home/httpd/html/dane.html";

#require cgi-lib.pl
require "cgi-lib.pl";

&ReadParse;

#otwiera plik i dostawia do niego nowe dane
open(DB,">>$file");

#drukuje informacje
print DB "\n<B>$in{'name'}<BR>";
print DB "\n$in{'location'}</B><BR>";
print DB "\n$in{'comments'}<BR><HR>\n";

close DB;

And html file:

<html>
<head>
<title>Test</title>
</head>

<form method=post action="../cgi-bin/dane.pl">
Nazwa:<input name="name"><br>
Adres:<input name="location"><br>
<BR>Komentarz:<br>
<textarea name="comments">
</textarea>
<input type="submit">
</form>

<b>Show me entries:</b>
<BR>

When I submit this form I receiving a
"Documen contains no data"
message. But when I reload form page I see new entries.
dane.pl has 755
dane.html has 666

please help me,
JerzyO.
0
Comment
Question by:jerzyk
[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 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1831066
why don't you try putting some data in the document:
print "Content-type: text/html\n\n";
print qq(<html><head><title>document</title></head>\n <body>form submitted</body></html>\n);

0
 

Accepted Solution

by:
steve_howell earned 100 total points
ID: 1831067
Ozo's right: you're getting "document has no data," because you never wrote data to standard output in your CGI program.  A web server that supports CGI will display to the browser only what your program writes to standard output.  Your technique of writing a new HTML file every time doesn't really fit the CGI model, although you could have your CGI program write a new version of that file and immediately write it to standard output.

If, for some reason, you don't want the screen to change when you hit your page, you can send an HTTP header like this from your program:

Status: 204 No Content\n\n

When the browser sees this, it will know that your program is just doing something on the back end, and you don't want to redraw anything.


0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

751 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