RE: Error Code Airhead

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[snip]
> I'm sure I'm missing something really obvious here but
> can't see it. There is a form where one of two promotional codes can
> be entered. I check for the these codes and give the user an error
> message if they enter the wrong code. First one doesn't work, second
> one does with only one code.   
> 
> //always gives error message even if one of the two codes entered: if
> 	($Promotion_Sub == 'Checked' && ($code != 'D04E' || $code !=
> 	'Y04KG')) { echo " <html>
> 	<head>
> 	<title>Error</title>
> 	</head>
> 	<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000ff\"
> vlink=\"#660099\">
> 	<h3>Error</h3>
> 
> 	<p>Sorry, that code is invalid.</p>
> -----------------
> //works:
> if ($Promotion_Sub == 'Checked' && $code != 'D04E') {
[/snip]

I'm not really sure how to answer this!  How does this relate to the US
election?  Isn't this an election list?  HA HA HA HA, just kidding ;o)

You need to check that the code entered doesn't match both valid codes.

Try this instead:

If ($Promotion_Sub == 'Checked' && $code != 'D04E' && $code != 'Y04KG')
{

Do error stuff

}

With the code you have above, it will always give the error message
because you're checking to see if $code is not equal to the first value,
OR if it is not equal to the second value.  So with that, the code
supplied might well match the first ('D04E') but since that obviously
doesn't match the second, it's going to throw the error.

HTH,

Pablo

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux