John,

Thanks for the idea.

I'd thought of using JavaScript, but I'm sunk if the user has Jscript turned
off on their PC and I felt I wanted a little more surety on this being
checked. I am going to re-visit the idea, however.

My current Perl code does catch the error and return a form to the user so
that they can reflect on their evil ways and correct their misdeeds. The
script won't abort on 'em. (I'm considering a file-based counter, so that
maybe the third time the same user flubs up I can really slap their paw,
however; but that's an "enhancement" <g>)

Thanks.

John--
[EMAIL PROTECTED]

-----Original Message-----
From: Moon, John [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 23, 2001 2:22 PM
To: John
Cc: Beginners-CGI
Subject: RE: CGI::POST_MAX use and control


For myself I would prefer not to "abort" a script on this type of error...
A simple JavaScript to check for the max size of a textarea and an "alert"
is a much better way to handle this type of error, in my option... see
"OnSubmit" in some JavaScript reference and you should be able to find an
example like ..

O'Reilly's "JavaScript The Definitive Guide", Chapter 16: Forms and Form
Elements,  16.5 Form Verification Example

Hope this give you some ideas...

jwm

-----Original Message-----
From: Lisa Nyman [mailto:[EMAIL PROTECTED]]
Sent: August 23, 2001 13:20
To: John
Cc: Beginners-CGI
Subject: Re: CGI::POST_MAX use and control


Hi,

On Thu, 23 Aug 2001, John wrote:

> The current incarnation of my script blows itself out of the water if the
> $user_body variable (the TEXTAREA source) is greater than 4K, for example.
> This is good.
>
> I would like to be able to capture and control the process so that I don't
> get rudely blown out of the water with a crude 500 Server message (this
> would be gooder! <g>). I would like to: a)generate a useful message and,
b)
> set some flags, do some more processing, and send a message back to the
user
> to give them an opportunity to correct their input and atone for their
sins.
> (This would be more gooder! <g>)

In general, you always want to die gracefully from within a web script so
the error is logged and the user doesn't get an icky 500 error page.

For example, in database apps I write, for any error, I tell the user the
database is unavailable and I log the error.

The following has worked for me when dealing with POST_MAX:

use CGI qw/:standard/;
$CGI::POST_MAX=1024 * 10;
$CGI::DISABLE_UPLOADS = 1;
$| = 1;

my $page = new CGI;

print $page->header;

$run = $page->param('RUN');
if (!$run && cgi_error()) {
        # do whatever you do for an error
        &dieWell ("413: Max Posting surpassed.");
        }

sub dieWell  {
        my $message = shift;
        # remember to print proper headers if not done by now
        print "$thanks_for_playing_message\n";
        # do logging of $message if you want, send yourself email, whatever
        &footer;  # end my html -
        exit;
        }


Lisa Wolfisch Nyman  <[EMAIL PROTECTED]>  IT Warrior Princess
"Life is too short to wear ugly underwear."
Get the facts at http://quickfacts.census.gov/






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to