This is a difficult question to answer. There are several things I'd need to know before I could begin to guess at what you're asking:
- What is the purpose of this section of the program?
- What does $accountID signify?
- What does $accountAD signify?
- What does $unverified signify?
- What kind of information is in the database?
- What do you mean by "if both variables are inside both the value and the key"?
- When you say "I'll try comparing... to the value of the key", what is "the key"?
- In your code snippet, what is the first conditional?
I'd love to give you an answer, but without more information either this question is unanswerable or my reading comprehension has suddenly taken a nosedive.
| [reply] [d/l] [select] |
The purpose of the section I posted was to take params from the url and verify they were in the database.
- $accountAD is an email address (ie. me@you.com)
- $accountID is a 17 digit random string (ie. 1234567asdfgh6324)
- $unverify is a database to store all unverified email addresses before it's checked by url_params and the database.
- The database stores information like this $dbm1{"$accountID"} = $form{'usermail'}; .
- I meant to ask if both variables from the url_param where checked against the $dbm value and key or just the $dbm{key}.
- Maybe I have my terms messed up. I'm saying $dbm{x} is the key and everything after the = is the value.
- This is a revised version of the snippet I gave you but I'm still having a problem nonetheless. I still need to know if my checking of the inputted params are what I think they're supposed to do. Look for the ****** in the code below for the associated snippet.
If you have any other questions let me know, thanks for your help!
#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);
use CGI;
use POSIX;
require SDBM_File;
#
# Define our constants
#
my $sendmail = "/usr/lib/sendmail";
my $adminmail = "test\@test.com";
my($verified, $unverified, $ID);
my @chars = ( "A" .. "Z", "a" .. "z", 0 .. 9, qw(! @ $ % ^ & * ) );
#
# Define our dynamic input
#
my $query = CGI->new;
print $query->header;
my %form = %{$query->Vars};
my $accountID = $query->url_param('accountID');
my $accountAD = $query->url_param('accountAD');
my (%dbm1, %dbm2);
my $dbm1 = "unverified.dbm";
my $dbm2 = "verified.dbm";
tie (%dbm1, 'SDBM_File', $dbm1, O_CREAT|O_RDWR, 0644)
|| die "Died tying database\nReason: $!\n";
tie (%dbm2, 'SDBM_File', $dbm2, O_CREAT|O_RDWR, 0644)
|| die "Died tying database\nReason: $!\n";
#
# If form was completed generate an ID, store them to database, email
+user
#
if ($form{'usermail'}) {
&generate_id;
&email;
print "An email has been sent to $form{'usermail'} for verification.
+<br><br>\n";
$dbm1{$form{'usermail'}} = "$ID";
}
#
# Or if url param's are present and checked add them to other DB and r
+emove them from $unverified
#
***************The error is probably in this segment***
else {
my $unverified = $accountID;
my $verified = "$accountAD";
if ($dbm1{"$accountAD"} && $dbm1{"$accountAD"} =~ /^$accountAD$/) {
$dbm2{"$verified"} = "$accountAD";
print "You have been added to the mailing list successfully!\n";
} else {
print "Registration failed!<br><br>\n";
print "\$accountID: $accountID .<br>\n";
print "\$accountAD: $accountAD .<br>\n";
}
}
***** error probably above this line
sub email {
$accountAD = "$form{'usermail'}";
open (MAIL, "|$sendmail -t") or die "Cannot access mail";
print MAIL "To: $form{'usermail'}\n";
print MAIL "From: $adminmail\n";
print MAIL "Subject: Verify your Email Address\n\n";
print MAIL "http://sulfericacid.perlmonk.org/evs/revised.pl?accountI
+D=$accountID&accountAD=$accountAD\n";
close (MAIL);
}
sub generate_id {
do { $accountID = join '', map { $chars[ rand @chars ] } 1..17; }
while grep {$_ eq $ID} my @used;
print $ID;
# my @unverified_emails=($form{'usermail'}, $accountID);
# $unverified = join "::",@unverified_emails;
#$dbm{"$unverified"}= join "::",@unverified_emails;
#foreach my $mail (split /::/, $dbm{'notverified'}) {
# print "$mail is not verified!\n";
#}
}
untie(%dbm1);
untie(%dbm2);
"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"
sulfericacid
| [reply] [d/l] |
It's a little difficult to parse :), and as ever,it'd help if you posted some more code, but maybe you're simply looking for something like...
if ($dbm{$accountAD} eq $accountID){
do_something(); # got an existing one;
}
elsif (defined $dbm{$accountAD}) {
do_something_else(); # a mismatch?
}
else {
$dbm{$accountAD} = $accountID; #set a new one
}
Hope this helps. | [reply] [d/l] |