use strict;
use CGI qw/:standard/;
if (param()) {
if (param('email')=~/\w+@\w+/) {
print header,
start_html('Thank you'),
h1('Thank you'),
p, param('name'), ' now that we have your e-mail address w
+e will send lots of nice spam to you at ', param('email'), '!', p;
}
else {
formmaker('You must provide an email address!');
}
}
else {
formmaker();
}
sub formmaker {
print header,
start_html('A Form with Sticky Fields'),
h1('A Form with Sticky Fields'), p;
my $message = shift;
print $message, p if $message;
print start_form,
"What's your name? ",textfield('name'),p,
"What's your email? ",textfield('email'), p,
,p,
submit,
end_form,
hr;
}
As you will see when you test this script, the fields are 'sticky', i.e. they keep their values between invocations.
CountZero "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law
|