#!/usr/bin/perl -Tw ############################################################ ## Written and copyright 2002 by ## Jacqueline D. Hamilton (kira@cgi101.com) ## ## This code is excerpted from "CGI Programming 201" ## (http://www.cgi101.com/advanced) ## ## You may use this code on your own website, however ## you may not publish or sell any copy or derivative work ## without permission of the author. ############################################################# use strict; use lib '.'; use MyBoard; # declare variables my($forum_id, $sth, $rv, $f, $count); # here we untaint the query string if ($cgi->param('forum') =~ /^(\d+)$/) { $forum_id = $1; } else { &dienice($cgi->param('forum') . " isn't a valid forum number."); } # get the name & info on this forum from the forums table $sth = $dbh->prepare("select * from forums where id=$forum_id") or &dbdie; $rv = $sth->execute; $f = $sth->fetchrow_hashref; &do_header("$f->{name} Forum"); print qq(

$f->{name} Forum

\n); print $f->{desc}; &do_nav; # fetch the individual messages in the forum, and display the info. $count = 0; $sth = $dbh->prepare("select * from messages where forum=$forum_id and thread_id=0 order by date desc") or &dbdie; $rv = $sth->execute; while ($f = $sth->fetchrow_hashref) { print qq($f->{subject} ($f->{author})
\n); $count = $count + 1; } if ($count == 0) { print qq(No messages.

\n); } &do_nav; &do_footer; sub do_nav { print qq(


\n); print qq(

Compose New Message | ); print qq(Search This Forum

); print qq(

\n); }