Gossamer Forum
Home : Products : DBMan : Customization :

VERY curious CGI behaviour!

Quote Reply
VERY curious CGI behaviour!
This may be trivial (I hope so) so forgive me, but I'm somewhat new to CGI, however not new to perl.
I have done some modifications to the db.cgi and the html.pl script and all is working well.
Now for the funny behaviour.
Sometimes, when I hit the browser Back or Refresh/Reload button, the html code is displayed in the browser window rather than the cgi executing. Shocked
I am at a loss as to why this is happening. File permissions are obviously OK, since this is not a consistent problem.
Is this a common issue regarding cgi scripts??
BTW, this happens in both IE and Netscape (latest versions.)

puzzled.
afbknudsen@hotmail.com


Quote Reply
Re: VERY curious CGI behaviour! In reply to
I will agree. It's very curious! Smile

I'm not sure what would cause this, but it sounds like sometimes the html headers aren't being sent to the browser. It's really hard to pin down an occasional problem, though.


JPD
Quote Reply
Re: VERY curious CGI behaviour! In reply to
Wow, thanks for the quick reply JPD!!!

Well...Smile I did modify the html_print_headers sub as follows:

Code:
sub html_print_headers {
# --------------------------------------------------------
# Print out the headers if they haven't already been printed.

if (!$html_headers_printed) {
print qq|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>$html_title -- $_[0]</title>
</head>

|;
$html_headers_printed = 1;
}
}
I also removed all the <html><head> etc. from the start of subs calling the print headers sub so they look like this:
Code:
sub html_home {
# --------------------------------------------------------
# The database manager home page.

html_print_headers("Main Menu");
print qq|

<body >
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=$g_width align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Main Menu</b>
...
See anything wrong with that? I was hoping not Wink

Quote Reply
Re: VERY curious CGI behaviour! In reply to
Since you seem to be having a problem after making the change, I would suggest you go back to the way it was before. Your code seems okay, but I don't know what sort of problems it might cause with CGI.


JPD
Quote Reply
Re: VERY curious CGI behaviour! In reply to
I think you would be better off by replacing your sub html_print_headers back to the original.

Then what I did was to include my html and body tags within the following subs:

sub html_page_top & sub html_error_page_top

&html_print_headers;
print qq|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html><head><title>$html_title: $page_title</title></head>
<body background="../../img/auctback.gif" TEXT="#110000" LINK="#3333FF" VLINK="#23238E" ALINK="#660000">
<A NAME="top"></A>
etc.

Try moving your body tags to these subs and see if that stop the problem.

Hope this helps Smile