You are here: Re: [PHP] Security/$_REQUEST vars... How do you do it? « PHP « IT news, forums, messages
Re: [PHP] Security/$_REQUEST vars... How do you do it?

Posted by comex on 12/04/05 01:29

> if((isset($_REQUEST['sub'])) && (!empty($_REQUEST['sub']))) {
empty is a language construct, not a function, so that is not
necessary. You can just do !empty(...).


> $error = false;
> return $error;
In your security_check function, you set $error to false in the
beginning for no reason; in fact, you don't need to use it all. You
could return false or return true, or simply
return !empty($x);

However, that doesn't actually work because when you call the
function, it assumes that $_REQUEST[whatever] is defined and could
cause a notice if it isn't; and $x will always be defined, even if set
to null.

Since your variables are coming from REQUEST anyway, you could write
it like this:
function security_check($x) {
return !empty($_REQUEST[$x]);
}

Then, if(!security_check('sub')) { ... }

Of course, there are people who can be more helpful and will probably
tell you to do more than just check if the variable exists.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация