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:

<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>
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.

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?


In reply to CGI:Application and HTML::Template parameter passing by emgrasso

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.