I write two file main.php and download.php.
main.php
echo"<form action='download.php' method='post'>"
for(i = 0; i < 10; i++){
echo"<input type='submit' name='$i'>";
}
In download.php, I want to know which name’s button is pressed? (from 1 to 10 to download the file), so that I can use it in download.php to download file.
I have tried to use $_POST[“$i”] but failed.
What if the $i is a random filename?
Thx!
complete code
main.php:http://codepad.org/4zXPhqFy
Access
$_POSTvia$key => $valuein a loop. Exclude other values you know the names of (if you have others).Or, use
ctype_digit()on the post key to determine if it is numeric, excluding any other string keys you may have in there.Note that unless you are using HTML5,
nameattributes must begin with a letter, not a number. If you are using HTML5, anything but an empty string is allowable in thename.