Hello everyone,
I am trying to create a simple cgi script that if a user enters the
correct information on a contest form, they are entered into a flat-file DB.
This I have conquered. My next feat is that before I write their personal
information into the DB, I am comparing 3 fields from the DB to 3 fields
being submitted by the user for duplicate submissions in sub one_time (the
fields are phone number fields). The problem is, is that I never get a
match and the user is able to submit an infinite amount of time. Here is my
source code. It's only about 65 lines. Thank you for your help!
Jon Riddle
Interactive Gallery Inc.
Phone- 818-501-4486 ext. 3037
Email- [EMAIL PROTECTED]
"The three great virtues of a programmer are
laziness, impatience and hubris.
Larry Wall "
#!/usr/local/bin/perl -w
use CGI;
use CGI::Carp qw(carpout fatalsToBrowser);
$Q = CGI;
$content_length = $ENV{'CONTENT_LENGTH'};
read (STDIN, $posted_information, $content_length);
$posted_information =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
$posted_information =~ s/\+/ /g;
@fields = split (/&/, $posted_information);
($label, $name) = split (/=/, $fields[0]);
($label, $street) = split (/=/, $fields[1]);
($label, $city) = split (/=/, $fields[2]);
($label, $state) = split (/=/, $fields[3]);
($label, $zip) = split (/=/, $fields[4]);
($label, $PHONE_AREA) = split (/=/, $fields[5]);
($label, $PHONE_PRE) = split (/=/, $fields[6]);
($label, $PHONE_SUFF) = split (/=/, $fields[7]);
($label, $serviceProvider) = split (/=/, $fields[8]);
($label, $lapDance) = split (/=/, $fields[9]);
($label, $lapDance2) = split (/=/, $fields[10]);
($label, $lapDance3) = split (/=/, $fields[11]);
($label, $lapDance4) = split (/=/, $fields[12]);
($label, $lapDance5) = split (/=/, $fields[13]);
#Compares correct anwsers
$lapResults .= ",$lapDance,$lapDance2,$lapDance3,$lapDance4,$lapDance5";
if ($lapResults eq
",AvaVincent,JessicaDrake,JewellDeNyle,ShaylaLaVeaux,ShaySweet") { $correct
= 1}
if (!$correct) {
print $Q->redirect('http://www.ten.com/contest/thanklost.htm');
}
else {
if (one_time(1)) {
print
$Q->redirect('http://www.ten.com/contest/already.html');
}
else {
open (OUTPUT, ">> lapdance.db") || die "Cannot open lapdance.db: $!";
print OUTPUT $name, ":", $street, ":", $city, ":", $state, ":",
$zip,":", $PHONE_AREA, ":", $PHONE_PRE, ":", $PHONE_SUFF,"\n";
close OUTPUT;
print $Q->redirect('http://www.ten.com/contest/thankwon.htm');
}
}
# Routine that checks DB for previous valid
# entry comparing telephone number
sub one_time {
open (VARIFY, "< lapdance.db") || die "Cannot open lapdance.db: $!";
while (<VARIFY>) {
$stats = <VARIFY>;
$compare = { split (/:/, $stats)};
@records = \$compare;
if (($records[6] eq $PHONE_AREA) && ($records[7] eq
$PHONE_PRE) && ($records[8] eq $PHONE_SUFF)) {
$sorry = 1;
}
}
close VARIFY;
return $sorry;
}
##################### EOF ###############################