Solved

Document contains no data

Posted on 1997-11-04
2
152 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
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

762 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

20 Experts available now in Live!

Get 1:1 Help Now