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.


In reply to Re: variables get overwritten (loop problem? i dunno) by gjb
in thread variables get overwritten (loop problem? i dunno) by vxp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.