Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Parameter testing

by sulfericacid (Deacon)
on Jul 21, 2003 at 21:12 UTC ( [id://276469]=perlquestion: print w/replies, xml ) Need Help??

sulfericacid has asked for the wisdom of the Perl Monks concerning the following question:

$accountID and $accountAD are both url_params (all the foreaches are just db test prints).

This collects information from a url like:

http://sulfericacid.perlmonk.org/evs/evs.pl?accountID=nKc5oWPOnaPeTHCz +f&accountAD=sulfericacid@earthlink.net .
The snippet below is supposed to check both AD and ID against the database to be sure that the ID exists and that its value = AD.

If you switch the characters in accountID around it gives off "Email address not found" when I expected a different error.

If you switch the accountAD around but leave the original accountID the same, it'll add whatever email address you gave it to the db and say it was fine.

Can someone tell me what's wrong with this checking? I need it to be sure that ID exists and that it equals AD or it should exit. Any suggestions would be much appreciated.

if ( $accountID && ( $accountAD ne '' ) ) { if ( exists $unv{$accountID} ) { print "\$accountID found: $unv{$accountID}<br>"; if ( $unv{$accountID} = $accountAD ) { $dbm{$accountAD} = $accountAD; delete $unv{$ID}; print "Your address has been indexed successfully!<br> +"; print qq(Please click <a href="$url">here</a> to submi +t another address); exit; } else { print "Registration didn't match.<br>"; print qq(Please click <a href="$url">here</a> to resen +d information); foreach (keys %unv) { print "$_ => $unv{$_}<br>"; exit; } } } else { print "Email address not found. Please re-submit your + details.<br>"; print qq(Please click <a href="$url">here</a> to try a +gain); exit; } } }


"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

Replies are listed 'Best First'.
Re: Parameter testing
by jsprat (Curate) on Jul 21, 2003 at 21:24 UTC
    if ( $unv{$accountID} = $accountAD ) { ======================^^

    Changing the '=' to 'eq' should correct it. Do you use warnings;? There is a warning (Found = in conditional, should be ==) you will see if you enable warnings.

    HTH

    Update: It should be eq, not == Thanks for the heads up Enlil

      I wasn't using use warnings; but I added that and tested the script before changing your suggestion. It didn't give off any error in my program or on the web. I changed the = to == but the same problems are present. As long as the ID exists, the AD doesn't matter.

      "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
        It looks to me like you should be using 'eq' not '==' because both ID and AD are not numeric.
Re: Parameter testing
by tadman (Prior) on Jul 21, 2003 at 21:33 UTC
    jsprat had the right idea, but since your account numbers seem to be alphanumeric, you'll need to use the eq comparison and not ==. A simple = is an assignment operator, not comparison.
      Ok, you were right. Adding eq fixed the entire problem. Now everything checks itself properly.

      Thank you everyone!

      "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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://276469]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-16 19:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found