i want to search for duplicate content in multiple fields. for example, if a spammer enters the same text in firstname, lastname, address, etc., i want to display an invalid entry error or just delete it. i've been using the following code:
$i = 0;
$howmany = @db_compare_fields; # number of elements
while ($howmany > $i) {
$j = $i + 1;
while ($howmany > $j) {
if ($in{$db_compare_fields[$i]} && $in{$db_compare_fields[$j]}) { # don't compare blank fields
if ($in{$db_compare_fields[$i]} eq $in{$db_compare_fields[$j]}) {
push (@input_err, "Invalid $db_compare_fields[$j]"); # show second field in error
} #if match
} # if fields not blank
$j++;
}
$i++;
}
@db_compare_fields is a list of the fields i want to compare
there must be a simpler way to do this. in addition, the error message contains duplicates. that is, if the person enters the same text in firstname, lastname, and phone, the error says
invalid phone
invalid phonei only want phone listed once. please help.
Code:
my ($i, $j, $howmany); $i = 0;
$howmany = @db_compare_fields; # number of elements
while ($howmany > $i) {
$j = $i + 1;
while ($howmany > $j) {
if ($in{$db_compare_fields[$i]} && $in{$db_compare_fields[$j]}) { # don't compare blank fields
if ($in{$db_compare_fields[$i]} eq $in{$db_compare_fields[$j]}) {
push (@input_err, "Invalid $db_compare_fields[$j]"); # show second field in error
} #if match
} # if fields not blank
$j++;
}
$i++;
}
@db_compare_fields is a list of the fields i want to compare
there must be a simpler way to do this. in addition, the error message contains duplicates. that is, if the person enters the same text in firstname, lastname, and phone, the error says
Code:
Invalid lastname invalid phone
invalid phone