Help. I am very new. I am using this script to create a guestbook entry; 
however I want it to ALSO email the results to me. I am willing to figure 
this out myself if someone can point me in the right direction.  There are 
several late night comments included. Ignore those of course...

Ken
*************

#!/usr/bin/perl -w

use 5.004;
use strict;
use CGI qw(:standard);
use Fcntl qw(:flock);

sub bail {
        my $error = "@_";
        print h1("Unexpected Error"), p($error), end_html;
        die $error;
}

my(
        $CHATNAME,
        $MAXSAVE,
        $TITLE,
        $cur,
        @entries,
        $entry
);

$TITLE = "I/O";
#$BOBBY = "your last ditch effort at input on my server";
$CHATNAME = "/usr/tmp/chatfile";
#either this must be a huge number, or you need to learn how to embed html
#into a perl script.  but in order to keep it from being kicked out
#the bottom on chatfile, this must be huge.  so figure out how
$MAXSAVE = 1000;

print header, start_html ("you are not a beautiful or unique snowflake");
print h1($TITLE);

#print header, start_html ($TITLE), h1($TITLE); 
#print body bgcolor="#000000" fontface="#FFFFFF"

#print ("your last ditch effort at input on my server");
#print ("the only say you will ever have at quantifier.org");
print h2("never allow yourself to believe that your opinions are important");
#print ($BOBBY);

$cur = CGI->new();
if ($cur->param("message")) {
    $cur->param("date", scalar localtime);
#    $cur->param("date", (date +"%D %H:%M"));
@entries = ($cur);
}

open(CHANDLE, "+< $CHATNAME") || bail("cannot open $CHATNAME: $!");

flock(CHANDLE, LOCK_EX) || bail("cannot flock $CHATNAME: $!");

while (!eof(CHANDLE) && @entries < $MAXSAVE) {
        $entry = CGI->new(\*CHANDLE);
        push @entries, $entry;
}
seek(CHANDLE, 0, 0) || bail("cannot rewind $CHATNAME: $!");
foreach $entry (@entries) {
        $entry->save(\*CHANDLE);
}
truncate(CHANDLE, tell(CHANDLE)) ||
                                bail("cannot truncate $CHATNAME: $!");
close(CHANDLE) || bail("cannot close $CHATNAME: $!");

print hr, start_form;
print ("email:", $cur->textfield(
        -NAME => "name",
        -SIZE => 35));
#watch, this is rediculously backwards.  drunk.
print ("name:", $cur->textfield(
        -NAME => "..email",
#how do i make spaces so i can take out ..email?    
        -SIZE => 35));
print p h2("input:", $cur->textfield(
        -NAME => "message",
        -OVERRIDE => 1,
        -SIZE => 100));
print p(submit("send"), reset("clear"));
print end_form, hr;

print h2("output:");
foreach $entry (@entries) {
#was only three
printf("%s %s [%s]:  %s",
#print date
$entry->param("date"),
$entry->param("email"),
#mod here, too, remember its backwards.
$entry->param("name"),
$entry->param("message"));

print br();
}
print end_html;

-- 
_________________________
[EMAIL PROTECTED]       
http://www.quantifier.org
_________________________
The Pig, if I am not mistaken,
Gives us ham and pork and Bacon.
Let others think his heart is big,
I think it stupid of the Pig.
                -- Ogden Nash

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to