CGI-FormMagick
view release on metacpan or search on metacpan
doc/FormMagick-FAQ.html view on Meta::CPAN
<P>
<H2><A NAME="how do i make my own validation routines">How do I make my own validation routines?</A></H2>
<P>Simply create a routine in your CGI script which accepts the data to
validate as an argument. Have it return ``OK'' on success or a detailed
error message on failure.</P>
<PRE>
sub my_validation {
my $data = shift;
if ($data =~ /$some_pattern/) {
return "OK";
} else {
return "That looks wrong to me.";
}
}</PRE>
<P>
<H2><A NAME="how do i add translations into another language">How do I add translations into another language?</A></H2>
<P>Use the <CODE>add_lexicon()</CODE> method:</P>
<PRE>
$f->add_lexicon("fr", { "Yes" => "Oui", "No" => "Non" });</PRE>
<P>
<H2><A NAME="how do i do extra processing when a user clicks next">How do I do extra processing when a user clicks ``Next''?</A></H2>
<P>Use a POST-EVENT on the PAGE element. Create a subroutine that does
what you want:</P>
<PRE>
sub process_credit_card {
my $cgi = shift;
my $cardnum = $cgi->param("cardnum");
my $response = do_processing($cardnum);
print "<p>$response</p>";
}</PRE>
<P>
<H2><A NAME="how do i choose which page to go to based on user input">How do I choose which page to go to based on user input?</A></H2>
<P>Use a PAGE POST-EVENT and set the value of the ``wherenext'' CGI
parameter:</P>
<PRE>
sub my_post_page_event {
my $cgi = shift;
if ($cgi->param("foo") eq "bar") {
$cgi->param(-name => "wherenext", -value => "GoToThisPageName")
} elsif ($cgi->param("had_enough") eq "Yes") {
$cgi->param(-name => "wherenext", -value => "Finish")
}
}</PRE>
<P>
<HR>
<H1><A NAME="troubleshooting">TROUBLESHOOTING</A></H1>
<P>
<H2><A NAME="general troubleshooting tips">General troubleshooting tips</A></H2>
<P>Try turning on debugging when you invoke FormMagick:
</P>
<PRE>
my $f = new CGI::FormMagick( DEBUG => 1 );</PRE>
<P>
<H2><A NAME="why isn't my data preserved from one page to the next">Why isn't my data preserved from one page to the next?</A></H2>
<P>You probably need to make your <CODE>session-tokens</CODE> directory writable and
executable by the web server. Either:</P>
<PRE>
chown www session-tokens
(assuming your webserver runs as the www user)
chmod 700 session-tokens</PRE>
<P>Or...</P>
<PRE>
chmod 777 session-tokens</PRE>
<P>Note that the latter allows anyone on the system to write to this
directory, and is a greater security risk than the former method.</P>
</BODY>
</HTML>
( run in 1.052 second using v1.01-cache-2.11-cpan-39bf76dae61 )