The best practice for testing to see if you received a variable from the form (which in the case of a checkbox, only happens when it is checked) is to test using this...

<?php
if ( isSet($string) ) { ... } //true if and only if the variable is set
?>

The function tests to see if the variable has been set, regardless of its contents.

By the way, if anyone's curious, when you do make a checkbox without specifying the value attribute, the value sent from the form for that checkbox becomes 'on'. (That's for HTML in general, not PHP-specific).

===================However, if you added a new textbox before these elements, the checkboxes indexes become 1 - 3 instead of 0 - 2; That can mess up what ever code you create depending on those indexes.

Instead, try referencing your html arrays in JavaScript this way. I know it works in Netscape 4 & IE 6, I hope it to some extent is universal...===================

I think that behavior of PHP which forces to use [] after a name of 'select' control with multiple attribute specified is very unfortunate. I understand it comes from old times when registerglobals = on was commonly used. But it creates incompatibility between PHP and ASP or other server-side scripting languages. The same HTML page with 'select' control cannot post to PHP and ASP server pages, because ASP does not require [] and automatically recognize when arrays are posted.

I needed to post html form through image input element. But my problem was I had to use multiple image-buttons, each one for a single row of form table. Pressing the button was mention to tell script to delete this row from table and also (in the same request) save other data from the form table.I wrote simple test-script to see what variable I should check for in a script:

Concerning XHTML Strict and array notation in forms, hopefully the information below will be useful:

If I have a form, name="f", and, say, an input text box, name="user_data[Password]", then in Javascript, to reference it I would do something like:

var foo = f['user_data[Password]'].value;

Now, say that in making the switch to XHTML strict, I decide to fully embrace standards compliance, and change my form to id="f", and the input text box to id="user_data[Password]"

Because these have id instead of name, I discover, that all my javascript validation routines just broke. It seems that I have to now change all my js code to something like:

document.getElementById( 'user_data[Password]' ).focus();

I test this on all the major modern browsers, and it works well. I'm thinking, Great! Until I try to validate said page. It turns out that the bracket characters are invalid in id attributes. Ack! So I read this thread:

What does this mean, I start asking myself? Do I have to abandon my goal to migrate to XHTML strict? Transitional seems so unsatisfying. And why bother with a technique that seems to work on most browsers, if it's broken. Alas, there is hope.

But then I read http://www.w3.org/TR/xhtml1/#h-4.10 carefully. It says "name" is deprecated as a form attribute, but *NOT* specifically as an attribute in form *elements*. It seems my solution is to use "id" for the form itself, but I can legally use "name" for the individual form components, such as select and text input boxes. I get the impression that "name" as an attribute is eventually going away completely, but in extensive testing using the W3C validator, it passes "name" on form components, as long as "id" (or, strangely, nothing) is used to denote the form itself.

So for XHTML strict, the bottom line: 1. form, use id, not name 2. input, use id if you can, but if you need to use bracketed notation (for example, passing PHP arrays), i.e., foo[], you *MUST* use name for XHTML strict validation.

There may be operating systems that want utf8 encoding, other than WINNT. Even this latter one won't work on those systems. I don't know about any possibility to determine immediately which encoding to be used on the file system of the server...

Well, I was working on this one project, on the assumption that I could get the values of all elements with the same name from an appropriately named array. Well, I was *very* disappointed when I couldn't, so I made it so I did anyway.

The following script should convert the raw post data to a $_POST variable, with form data from SELECT elements and their ilk being transformed into an array. It's heavily unoptimized, and I probably missed something, but it's relatively easy to read. I welcome corrections.