#!/usr/local/bin/perl # unbuffer output so that we can see it as it comes # out, rather than waiting for buffers to flush $| = 1; $ENV{'PATH'}="/bin:/usr/bin:/usr/ucb"; # Adjust these constants to whatever is appropriate for your site: $MAIL = '/usr/lib/sendmail';# path to mail program $MAIL_TO = 'webmaster'; # who to send the mail to use CGI; $query = new CGI; print $query->header; print $query->start_html('Feedback Form'); unless ($query->param) { &print_prompt($query); } else { &do_work($query); } &print_signature; # ------------ Create the form ----------- sub print_prompt { my($q) = @_; print <Feedback Form How are we doing? Use this form to tell us what you like and dislike about our pages. After filling out the form, press "Mail these comments" to mail your comments out to us.
END ; print $q->start_form, "Please enter your name: ",$q->textfield(-name=>'name',-size=>30),"
", "Your e-mail address: ",$q->textfield(-name=>'address',-size=>30),"

", "How would you rate the organization of these pages?", $q->popup_menu(-name=>'organization', -values=>['Excellent','Good','Middling','Poor']),"

", "How would you rate its contents?", $q->popup_menu(-name=>'contents', -values=>['Excellent','Good','Middling','Poor']),"

", "Can you think of ways to improve this site?
", $q->textarea(-name=>'improvements', -rows=>5,-cols=>50),"

", "Other comments?
", $q->textarea(-name=>'comments', -rows=>5,-cols=>50),"

", $q->reset, $q->submit(-label=>'Mail these comments'), $q->end_form(); } # ---------- E-mail the form out --------- # One copy gets e-mailed. The other gets displayed # on the screen so that the remote user knows something happened. sub do_work { my($q) = @_; my($message); # Import the parameters into a series of variables in the 'Q' # namespace. $q->import_names('Q'); # If extra path information was passed to the script, # then incorporate it into the subject line. Otherwise # use a generic subject line. my($subject) = "Feedback on the Web site"; my($path) = $q->path_info; my($self) = $q->url; $subject = "Feedback on Web page \"$path\"" if $path; # Incorporate the comments into a memo $message = <Feedback Results Thank you for your feedback. The following has been mailed to $MAIL_TO:

$message
Send another comment END } # ------------- The rest of this stuff is boilerplate ------ sub print_signature { print <
webmaster\@your.site.org

Jump to the welcome page END }