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 7678483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:39:30+00:00 2026-05-31T17:39:30+00:00

I am trying to create a php file that would scan a directory, make

  • 0

I am trying to create a php file that would scan a directory, make a list of dynamic radio buttons and have the user select one and submit it and it shall pass it into another php file that would send it off, but I am having trouble with the submit button. Was wondering if I could get some answers, been looking around the net and haven’t been able to find anything.
Here is my code:

<?php

ini_set('display_errors',true);
//Scan directory (ripped from another site)
$directory = opendir("download");
while($entry = readdir($directory)) {
    $dirArray[] = $entry;
}
closedir($directory);
$indexCount = count($dirArray);
sort($dirArray);

//Make the Radio Button list
$RList = "";
for($i=2; $i<count($dirArray); $i++) {
    $value = $dirArray[$i];
    $RList .= "<input type=\"radio\" name=\"Files\" value=".$value." />".$value."<br />";
}
//Submit button
$RButton = '<input type="button" value="Submit" 
onclick="location.href=\'http://localhost/appClient/load.php?file='.$value.'\'">';
echo $RList.$RButton;
#echo $_POST["Files"];

?>

Thanks

  • 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-05-31T17:39:31+00:00Added an answer on May 31, 2026 at 5:39 pm

    It looks like you’re passing $value to the onclick event. Since that’s outside of the PHP loop, it will end up always being the last $value.

    To fix this, use javascript to get the selected value from the radio and append that to the onclick redirect.

    Better yet, your load.php file should just simple check the ‘Files’ key in your $_POST and use that, instead of using GET. That’s the point of submitting the radio button, after all.

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

Sidebar

Related Questions

I am trying to create a php file that adds a user and create
I have a directory named dollars that contains a file index.php . I would
I'm trying to create a PHP file that calls a function in another file.
Here's the problem I'm trying to solve: I have a dynamic php-driven website that
I'm trying to create a PHP file that will export the contents of 4
I'm trying to create system users with a php script securely, In that, I'd
I'm trying to create a generic class in PHP that will provide a way
I am trying to read in a file that has HTML list items with
I am trying to create a file that is essentially an e-mail with headers
I'm trying to create a string to pass to a PHP file with numerous

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.