emgrasso has asked for the wisdom of the Perl Monks concerning the following question:
I am just learning CGI::Application. My first app is based closely on some examples I have found online, including http://www.sitepoint.com/article/cgi-application/1.
There is something very basic that I seem to be missing about passing information back and forth. I have verified that the sitepoint example works correctly in my environment and tweaked my code to be as similar to it as possible.
One of my templates ends with the lines:
Note that the <tmpl_var name=userid> displays the value of userid so I'm sure it is what I think it should be: 0 or the userid of the record that is being edited.<tmpl_var name=userid> <input type="Hidden" name="userid" value="<tmpl_var name=userid>"> <input type="Hidden" name="rm" value="maintain_user"> </form> </body> </html>
The maintain_user runmode looks like:
sub maintain_user { my $self = shift; my $q = $self->query; # validate the input use CGI::Application::Plugin::ValidateRM (qw/check_rm/); my ($results, $err_page) = $self->check_rm('admin_edit_user +', '_user_profile'); return $err_page if $err_page; if ($q->param('userid') == 0) { $self->_create_user(); } else { $self->_update_user(); } $self->param('message', 'User saved'); $self->admin_edit_user(); }
My problem is that $q->param('userid') seems to be always coming back empty, so the script always takes the create_user branch.
Devpopup shows incoming HTTP_REFERER http://localhost/cgi-bin/IncentivePoints.cgi/IncentivePoints.cgi?rm=admin_edit_user&userid=test3 and outgoing QUERY_STRING rm=admin_edit_user&userid=test3.
Is there a better way to do the parameter passing? Or a good way to debug the problem?
Or can anyone suggest what might be going wrong?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI:Application and HTML::Template parameter passing
by arpad.szasz (Pilgrim) on Sep 02, 2007 at 21:39 UTC | |
by meraxes (Friar) on Sep 03, 2007 at 01:14 UTC | |
|
Re: CGI:Application and HTML::Template parameter passing
by shmem (Chancellor) on Sep 03, 2007 at 18:49 UTC |