Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I have been using the construct, $$var, in my web page FORMS to pass arrays of form input, NAME, to my php script for processing. I haven't found any reference to this in books or searching. My question is, Is there any thing inherently faulty or risky with using $$ ? I'm not very skilled in php, but sometimes get something useful done....thanks in advance
Below I show some code snippets of how I'm using it to pass a list of form input NAMEs corresponding to the VALUEs (file names in my application)
In the php script that gets the form data I have:
......Code: Select all
// $numberf is the number of file names being passed from the form
for ( $count = 1; $count <= $numberf ; $count++){
$file_number = 'fil' . $count; // i.e., forming an array of values like: fil1, fil2, fil3, etc, as the loop progresses.
// then I use the construct:
$file_array[$count]=$$file_number;
}A similar loop was used to form the above list in the web page for NAME in the form INPUT; VALUE was a list of file names corresponding to the form input NAMES, as shown below.
.......
Code: Select all
// $nfiles is the number of files
echo "<table>";
echo "<form method=\"POST\" name=\"iamform\" action=\"file_delete.php\">";
echo "<INPUT TYPE=\"hidden\" NAME=\"numfiles\" VALUE=\"$nfiles\">";
for ( $count = 1; $count <= $nfiles ; $count++) {
$file_num = 'fil' . $count;
echo "<tr>";
echo "<td colspan='2' >";
echo "$filelist[$count]</td>";
$onefile = "$filelist[$count]";
echo "<td colspan='2' >";
echo "<INPUT TYPE=\"hidden\" NAME= \"$file_num\" VALUE=\"$onefile\">";Thanks,
Curt
Jcart | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]