#!/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; my($i, $sth, $rv); # do some error-checking - be sure they filled out all the fields # $cgi->param returns an array of the input field names. foreach $i ($cgi->param()) { if ($cgi->param($i) =~ /^\s*$/) { &dienice("$i was blank - please fill out all of the fields."); } } # this could be optional.... #if ($cgi->param('email') !~ /[\w\-]+\@[\w\-]+\.[\w\-]+/) { # &dienice("You didn't enter a valid e-mail address."); #} $sth = $dbh->prepare("insert into messages(author, subject, email, date, ip, message, thread_id) values(?,?,?, current_timestamp(),?,?,?)") or &dbdie; $sth->execute($cgi->param('name'), $cgi->param('subject'), $cgi->param('email'), $ENV{REMOTE_ADDR}, $cgi->param('message'), 0) or &dbdie; print $cgi->redirect("$url");