You are here: Re: [PHP] Type of form element « PHP « IT news, forums, messages
Re: [PHP] Type of form element

Posted by "Richard Lynch" on 10/31/05 08:18

On Sun, October 30, 2005 5:52 am, Marcus Bointon wrote:
> On 29 Oct 2005, at 20:59, Richard Lynch wrote:
>
>> So you will most likely be using isset($_POST['checkbox_name'])
>> rather
>> than testing for "on"
>
> I classify using isset for checking for the existence of array keys
> to be a bad habit as in some common cases it will not work as you
> expect, for example:
>
> <input type="checkbox" name="checkbox_name" />

A)
If you do not specify a "value=" in HTML for a checkbox, the value is
"on" by default.

So this should give you checkbox_name=on in a GET form.

If it doesn't, your browser is very very very broken.
[Probably Internet Explorer would be the one to get this wrong, if any
of them do]


B)
I dunno what version of PHP you are using, nor what php.ini settings
you have, but, at least in my version/settings:

http://example.com/test.php?checkbox_name=
isset($_GET['checkbox_name']) returns 1

Since HTTP and HTML have no concept of NULL, I'm not real worried that
$_GET will have NULL values in it.

I am certainly not going to pollute $_GET/$_POST/$_REQUEST by stuffing
NULL values into them!

If you want to do things that way, go right ahead.

But I really do believe isset($_POST['checkbox_name']) is a "good"
coding practice.

DSFDD

--
Like Music?
http://l-i-e.com/artists.htm

 

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

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