CGI form field generators fill in the current values of those fields (i.e. the values as they are in the param() method - normally the user input) if those values exist.

You can override those values by setting the param before creating the form fields:

$cgi->param("current","something else");
Also, you specify name/value pairs for hidden fields using either hidden($name,$value) or hidden(-name => $name, -value=>$value). Mixing them, as you're using for the user field does not work.

Also also, that code does not print anything, and if it does did it wouldn't print what you're claiming:

use CGI; use strict; use warnings; my $cgi = CGI->new; my @buffer; my $timestamp = time; my $user = "Me"; $cgi->param("current","something"); # set "current" push(@buffer, $cgi->start_form(-method => 'post' , -action => 'example +.cgi'), $cgi->submit(-name => 'edit_notes', -value=>$timestamp, -la +bel =>"edit"), $cgi->hidden(-name => 'user', $user), $cgi->hidden(-name => 'current', -value=>'example'), $cgi->end_form); print @buffer;
output:
<form method="post" action="example.cgi" enctype="multipart/form-data" +> <input type="submit" name="edit_notes" value="edit" /><input type="hid +den" name="user" value="" me /><input type="hidden" name="current" va +lue="something" /></form>
Note the problem caused by the wrong arguments in hidden( -name => 'user', $user)


In reply to Re: cgi issues by Joost
in thread cgi issues by jared

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.