in reply to CGI Login script error

In general, you'll find that you will save yourself a lot of grief if you print your header as early as possible in your script. That way if something goes wrong and you print an error message, it won't confuse the browser (which expects a particular Content-Type message as the first output of your script.

I use the fatalsToBrowser and warningsToBrowser in CGI::Carp recommended by Joost and ikegami extensively.

Remember, the user under which a CGI script is executed through the webserver is generally different from the command-line environment user, and will often lack file permissions and environment variables that you expect it to have.

Update: I notice that you do not specify any path for the password.txt file -- that seems to be one very good reason why it may fail to open the file, and (as pointed out by Joost, it will then print an error message which precedes the header (which is bad).


No good deed goes unpunished. -- (attributed to) Oscar Wilde

Replies are listed 'Best First'.
Re^2: CGI Login script error
by mattdope (Acolyte) on Jul 13, 2006 at 21:21 UTC
    Thanks for that. I am new to perl. I have placed the text file in the same directory as the cgi file. This is why I have not added a path. Is this the right thing to do?