Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8160501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:15:43+00:00 2026-06-06T18:15:43+00:00

I write two file main.php and download.php . main.php echo<form action=’download.php’ method=’post’> for(i =

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:15:45+00:00Added an answer on June 6, 2026 at 6:15 pm

    Access $_POST via $key => $value in a loop. Exclude other values you know the names of (if you have others).

    foreach ($_POST as $key => $value) {
      // Look for form keys not among other known ones
      if (!in_array($key, array('other','known','input','names')) {
        echo "You clicked $key";
      }
    }
    

    Or, use ctype_digit() on the post key to determine if it is numeric, excluding any other string keys you may have in there.

    foreach ($_POST as $key => $val) {
      if (ctype_digit($key)) {
        echo "You clicked $key";
        // Access it via $_POST[$key]
      }
    }
    

    Note that unless you are using HTML5, name attributes must begin with a letter, not a number. If you are using HTML5, anything but an empty string is allowable in the name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am appending two files in my .htaccess file and write these lines: php_value
I want to write a script that compares two directories. However, the file names
How to write two span tags or two elements inside an cake php link
My file looks like this: <MAIN> <SUB_MAIN>one</SUB_MAIN> <VER>version#</VER> (OTHER STUFF...) <LOCATION>PATH</LOCATION> </MAIN> <MAIN> <SUB_MAIN>two</SUB_MAIN>
Below are two programs that write 50,000,000 bytes to a file. The first program,
The setup: I have a standard .php file (index.php) that contains two includes, one
I write two windows console application as below class ProgramA { static void Main(string[]
I write a program in c++ with two files. main.cpp #include var.hpp #include <iostream>
I write two function, which callback will be invoke by the fn : var
I'm trying to write two classes, Sale and Register, for my OO class. Here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.