NAME

CGI::WPM::GuestBook - Perl module that is a subclass of CGI::WPM::Base and implements a complete guest book with unlimited questions that also e-mails submissions to the website owner.

DEPENDENCIES

Perl Version

5.004

Standard Modules

Fcntl
Symbol
Net::SMTP 2.15 (earlier versions may work)

Nonstandard Modules

CGI::WPM::Globals 0.35
CGI::WPM::Base 0.34
CGI::MultiValuedHash 1.06
HTML::FormTemplate 1.05

SYNOPSIS

Shortest Complete GuestBook Program -- Uses Default Question

my %CONFIG = (
	fn_messages => 'guestbook_messages.txt',  # file in SequentialFile format
);

require CGI::WPM::Globals;
my $globals = CGI::WPM::Globals->new( "/path/to/site/files" );  # msgs in here

$globals->site_title( 'Sample Web Site' );  # use this in e-mail subjects
$globals->site_owner_name( 'Darren Duncan' );  # send messages to him
$globals->site_owner_email( 'darren@sampleweb.net' );  # send messages here

require CGI::WPM::GuestBook;
$globals->move_site_prefs( \%CONFIG );
CGI::WPM::GuestBook->execute( $globals );

$globals->send_to_user();

Use Custom Questions Defined Here

my %CONFIG = (
	fn_messages => 'guestbook_messages.txt',  # file in SequentialFile format
	custom_fd => 1,
	field_defn => [
		{
			visible_title => "What's your age?",
			type => 'textfield',
			name => 'name',
			is_required => 1,
			validation_rule => '\d',
			error_message => 'You must enter a number.',
		}, {
			visible_title => "What's the combination?",
			type => 'checkbox_group',
			name => 'words',
			'values' => ['eenie', 'meenie', 'minie', 'moe'],
			default => ['eenie', 'minie'],
			labels => [qw( This That And Another )],
		}, {
			visible_title => "Who do you love?",
			type => 'textfield',
			name => 'name',
		}, {
			visible_title => "What's your favorite colour?",
			type => 'popup_menu',
			name => 'color',
			'values' => ['red', 'green', 'blue', 'chartreuse'],
		},
	],
);

Use Custom Questions Defined In Perl File

my %CONFIG = (
	fn_messages => 'guestbook_messages.txt',  # file in SequentialFile format
	custom_fd => 1,
	field_defn => 'guestbook_questions.txt',  # do Perl code to make array ref
);

Use Custom Questions Defined In SequentialFile File

my %CONFIG = (
	fn_messages => 'guestbook_messages.txt',  # file in SequentialFile format
	custom_fd => 1,
	field_defn => 'guestbook_questions.txt',  # file in SequentialFile format
	fd_in_seqf => 1,
);

Customize Subject Of Your Emails

my %CONFIG = (
	fn_messages => 'guestbook_messages.txt',
	email_subj => 'Your Visitor Has Left A Message',
);

Customize Webpage Intro Text

my %CONFIG = (
	fn_messages => 'guestbook_messages.txt',
	msg_new_title => 'Leave A Message',  # custom title for new messages
	msg_new_head => <<__endquote,   # custom heading for new messages
<H1>Leave A Message</H1>
<P>Please leave a message after the beep.  Answer the questions as faithfully
and truthfully as you can, as we have a lie detector set up and any false 
answers will be met with spam.</P>
__endquote
	msg_list_title => 'Previous Reflections',  # custom title when reading
	msg_list_head => <<__endquote,   # custom heading for reading
<H1>Wise Words That You Never Wrote</H1>
<P>Here are the messages that previous visitors wrote.  Please stay awhile 
and soak in the goodness.  You never know what you don't read.</P>
__endquote
);

DESCRIPTION

This POD is coming when I get the time to write it.

SYNTAX

This class does not export any functions or methods, so you need to call them using object notation. This means using Class->function() for functions and $object->method() for methods. If you are inheriting this class for your own modules, then that often means something like $self->method().

PUBLIC FUNCTIONS AND METHODS

This module inherits its entire public interface from CGI::WPM::Base. Please see the POD for that module so you know how to call this one.

PREFERENCES HANDLED BY THIS MODULE

This POD is coming when I get the time to write it.

custom_fd   # if true, we use a custom list of 
	# questions in the form; otherwise, we simply have a "message" field.
field_defn  # instruc for how to make form fields
	# If array ref, this is taken literally as list of definitions.
	# Otherwise, this is name of a file containing the definitions.
fd_in_seqf  # if true, above file is of the 
	# format that CGI::WPM::SequentialFile handles; else it is Perl code

fn_messages  # file messages go in, if filed

email_subj  # if set, use when sending e-mails

msg_new_title  # custom title for new messages
msg_new_head   # custom heading for new messages

msg_list_title  # custom title when reading
msg_list_head   # custom heading for reading

AUTHOR

Copyright (c) 1999-2001, Darren R. Duncan. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. However, I do request that this copyright information remain attached to the file. If you modify this module and redistribute a changed version then please attach a note listing the modifications.

I am always interested in knowing how my work helps others, so if you put this module to use in any of your own code then please send me the URL. Also, if you make modifications to the module because it doesn't work the way you need, please send me a copy so that I can roll desirable changes into the main release.

Address comments, suggestions, and bug reports to perl@DarrenDuncan.net.

SEE ALSO

perl(1), CGI::WPM::Base, CGI::WPM::Globals, HTML::FormTemplate, CGI::MultiValuedHash, Net::SMTP, Fcntl, Symbol.