in reply to Re: Re: Create required fields from form
in thread Create required fields from form

OK, we'll try.

Some questions first:

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

  • Comment on Re: Re: Re: Create required fields from form

Replies are listed 'Best First'.
Re: Re: Re: Re: Create required fields from form
by hcb (Initiate) on Jan 23, 2004 at 21:26 UTC
    Hi,

    My form is a static web-page which I created with FrontPage.

    The result is being processed with CGI.pm and Perl.

    I hope that helps.

    Thanks for helping me out.
      You could use the following as a skeleton for your script. The script both creates the page with the form (subroutine formmaker - the content of which you should replace with your webpage of course) and evaluates the returned parameters, if necessary re-displaying the form with an appropriate message to fill in the email-addres.

      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