On Mon, 23 Dec 2002 01:33:58 -0600, [EMAIL PROTECTED] (David
Gilden) wrote:

>I would like to be able to test for either of the two secret words
>but it seems to fail,  what am I missing?

>#!/usr/bin/perl 
>use CGI qw/:standard/;
>use CGI::Carp qw(fatalsToBrowser);
>use strict;
>
>my $qs = $ENV{'QUERY_STRING'};
>
>my $secret_word  = 'one';
>my $secret_word_guest  = 'two';
>
>if (($qs ne $secret_word_guest) or ($qs ne $secret_word)) {
>print "Bad password"; 
>exit;
>} 

Hi, I think your problem is that you are using
my $qs = $ENV{'QUERY_STRING'};  
and you are expecting it to match, it dosn't.

The $ENV{'QUERY_STRING'} actually looks something like
someword&someotherword  
or it may look like
someword=this&someword=that

So 
if (($qs ne $secret_word_guest) or ($qs ne $secret_word)) {
print "Bad password"; 

should always say Bad Password

You might be able to get away with using a regex instead of ne
if (($qs !~ $secret_word_guest) or ($qs !~ $secret_word)) {
print "Bad password"; 

But you are better off using the params given to you by
CGI.pm

if ( param('secret_word) ne $secret_word) or
          ( param('secret_word_guest) ne $secret_word_guest))
{print 'Bad Password'}

You might want to improve that logic, I'm not sure if it does
what you really intend. Like maybe:

if ( param('secret_word) eq $secret_word) or
          ( param('secret_word_guest) eq $secret_word_guest))
{print 'Good Password'}
else {print 'Bad Password'}











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

Reply via email to