in reply to Re^2: CGI simple but frustrating fault
in thread CGI simple but frustrating fault
You are calling the param method on an HTML::Tiny object as your test but this will always return true. Instead you should be performing a param-like test on your CGI object.
Suppose the submit input field of your form is called "foo". Then your code might be:
my $cgi = CGI->new; if ($cgi->param ('foo') { # have data to process } else { # no data, so print an empty form }
If you have an aversion to using CGI (or any of the smaller, lighter CGI modules) and want to do it by hand then you can test the 2 things you've already identified but in the outer test. eg.
if ($ENV{QUERY_STRING} || 'POST' eq $ENV{REQUEST_METHOD}) { # have data to process } else { # no data, so print an empty form }
🦛
|
|---|