in reply to variables get overwritten (loop problem? i dunno)

Okay, after staring at this for about half an hour I think I've got it. The error is in the HTML code you generate. Basically, you generate a table for each file found in a directory. This table contains some textfields, all of which are in the same form. Now all of the textfields for each of the files all have the same name, hence the data which is passed when the user hits the submit is just one of the fields with the same names, and that happens to be the first one.

To solve this, generate a form per file, each containing the table you already create and each containing a submit button. That way only one textfield will be passed upon submit and you'll get the user's choice rather than the first in the form.

Hope this helps, -gjb-

Update: Depanding on what you want to do in the CGI script that receives this form's info, it may be quite dangerous to have the file names in the HTML form since it's quite easy to fake a response with other file names (/etc/passwd comes to mind ;-) Since the checkbox already indicates which file has been selected, it might be better to compute the file name and info from that information in the receiving CGI scipt.

  • Comment on Re: variables get overwritten (loop problem? i dunno)

Replies are listed 'Best First'.
Re: Re: variables get overwritten (loop problem? i dunno)
by Anonymous Monk on Jan 04, 2003 at 05:35 UTC
    the only person to use this script (ever) is me. so i dont particularly care for the security of it.. ;) however. having a submit button per each picture is something im trying to avoid.. the purpose of this script is for me to easily add pictures to my webpage. the way im planning to do is by putting the new pictures in the directory, and have this script generate the form for me. that way ill easily see the filenames of the new pics, and can add description/imagelocation etc to my database. having to press 60+ submit buttons per once is tedious.. wanted to have one at the bottom. ;)

      Okay, I've made an attempt to make the code easier to understand by cleaning it up. Now have a look at the HTML that is generated by this code and you'll see how to get at the information for those images that have been selected using the checkboxes.

      Hope this helps, -gjb-