#!/usr/bin/perl -wT
############################################################
## 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;
&do_header("Delete Forum");
my($forum);
if ($ENV{QUERY_STRING} !~ /^(\d+)$/) {
&dienice("$ENV{QUERY_STRING} isn't a valid forum number.");
} else {
$forum = $1;
}
my($sth) = $dbh->prepare("select * from forums where id=?") or &dbdie;
my($rv) = $sth->execute($forum) or &dbdie;
if ($rv < 1) {
&dienice("Forum $forum doesn't exist.");
}
my($f);
$f = $sth->fetchrow_hashref;
$sth = $dbh->prepare("select count(*) from messages where forum=?") or &dbdie;
$rv = $sth->execute($forum) or &dbdie;
my($msgct) = $sth->fetchrow_array;
print <
Deleting forum \#$forum - $f->{name}
Or Return to Administration if you don't want to delete this forum.
EndHTML &do_footer;