Many thanks :)
I don't know whether I'm doing it correctly. I've a template page named form.tt. On this template, I've a template variable "key" (<TMPL_VAR key>). When a user A requests the page, the template variable is filled with a random MD5 hash. For illustration, here's the tear-down code:
use CGI;
our $q = new CGI;
sub do_form {
my $href;
$href->{key} = md5_hex(time() . '-' . $$ . '-' . rand());
to_template(
output => $href,
tmpl => 'form.tt'
);
}
sub to_template {
my %hash = @_;
print $q->header;
require Template;
my $template = HTML::Template -> new(filename => "/templates/$hash
+{tmpl}");
$template->param(map { defined $hash{output}->{$_} ? ($_ => $hash{
+output}->{$_}) : () } keys %{$hash{output}});
print $template->output;
}
sub process_form {
my $params = $q->Vars;
debug($params->{key});
}
Assume users A and B access the form at the same time, both should get a different key set on their respective form. Am I right?
Now A and B submit the form at the same instant, does the variable $params->{key} hold the right value of each user? Is it possible for user B's submission to get the value of A's key?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.