|
Posted by Erwin Moller on 05/29/07 16:52
Pablo wrote:
> Hi at all
> this code it'ld stop and exit if the user do not entered $dbf but it do
> not work
> Why?
>
> if (!isset($_GET['dbf']) || (isset($_GET['dbf']) && trim($_GET['dbf']) ==
> ''))
> {header('Location: http://www.pablo.es/index.php');
> exit();}
Hi,
Look at the logic:
if
(!isset($_GET['dbf']) || (isset($_GET['dbf']) && trim($_GET['dbf'])== ''))
My guess is you ment:
1) Demand that $_GET['dbf'] is set.
2) And if set, it must contain something (not empty string)
The above mixes the || and && is a strange way.
So try this:
if ( (isset($_GET['dbf']) && (trim($_GET['dbf']) != '')){
// OK
} else {
// Not OK
// header and exit.
}
You do not need the second isset-test this way.
When PHP evaluates the first part (isset($_GET['dbf']) to false and sees the
AND-logic operator && it doesn't even try to evaluate that, because the
if-statement can never evaluate to true.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|