Re: Form Processing Question - Empty Fields

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

 




On Wed, May 23, 2007 11:40 am, Stephen wrote:
> I have a script to process the post from a form.
>
>   The form is used to upload photos and has fields for the filename,
> alt text, caption and a checkbox to indicate if this photo is the
> main page image rotation.
>
>   I wanted to build a general routine to build the form to allow for a
> varying number of photos to upload.
>
>   I use main_image[] for the various checkboxes for each photo.
>
>   I see that the checkbox is *not* set, I get nothing back, and if the
> second photo is checked (and the first not checked), I get
> main_image[0] = 'on'.
>
>   And I see this happens for the caption[] array as well.
>
>   This seems to me to be pretty ugly.
>
>   Am I understanding this properly?
>
>   Do I really have to use main_image1, main_image2....

No.

You can use:
name="main_image[0]"
name="main_image[1]"
name="caption[0]"
name="caption[1]"

and the keys will be pre-set by the HTML to make sense of your data
structures.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
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