Checking whether the email is 'valid' is left as an excercise for the reader. The regex used should not even be considered to be the basis of such test.
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
In reply to Re: Re: Re: Re: Re: Create required fields from form
by CountZero
in thread Create required fields from form
by hcb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |