|
The text and programs here are from the first edition of CGI Programming 101. This has been replaced by the 2nd edition; please click here to view the updated material from the 2nd edition. |
| Name | Description | |
| survey.html | Survey Example | |
| survey.txt | Modified survey.cgi from Chapter 5 (source code) | |
| surveysumm.txt | Survey Summarizer (source code) | |
| surveysumm.cgi | Survey Summarizer Example |
# since some wisecrackers think it's cute to add html tags to their
# comments, we're ripping them out here.
$comments =~ s/</</g;
$comments =~ s/>/>/g;
# the following appends "$comments\n" to the end of the $commentary
# string.
# we only want to do this if the $comments are not blank...
if ($comments ne "") {
$commentary .= "$comments<p><hr>\n";
}
You may prefer to remove the tags before writing to survey.out in the survey.cgi itself, however that means the data itself will be harder to read. By removing the tags in the summary cgi, that preserves the data as entered by the surveyees, while making it readable (and unhackable) on the summary page.