------------------------------------------------------------ Listing 7: add-appointment.html % # Make sure that we got all required name-value pairs % unless ($begin_month and $begin_year and $begin_day and % $end_month and $end_year and $end_day and $email and $notes) { Missing information!

Missing information!

Sorry, but you need to provide us with the beginning and ending dates and times of your appointment, as well as some notes about it.

% # Make sure that the e-mail address looks somewhat valid % } elsif ($email !~ /[.\w]+@\w+\.\w{2,3}/) { Bad e-mail address!

Bad e-mail address!

Sorry, but the provided e-mail address does not look legal.

% # If we made it this far, try to create the appointment % } else { <%perl> # Set the current person by e-mail address my $set_person_successfully = $people->set_current_person_by_email($email); % if ($set_person_successfully) { <%perl> % if ($added_appointment_successfully) { Sucess!

Success!

We successfully added your appointment.

% } else { Error!

Error!

We were unable to add your appointment.

% } % } % } <%init> use People; use Appointments; my $people = new People; my $appointments = new Appointments; <%args> $email $begin_day $begin_month $begin_year $begin_hour $begin_minute $end_day $end_month $end_year $end_hour $end_minute $notes