Solved

Document contains no data

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

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…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

770 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