0

I'm trying to get a form to work with php. When I click submit a submit button nothing happens.

<?php 

if(isset($_POST['imageSelectButton']))
{
  echo "Test: ";
}
?>
<form id="setImages" action="index.php" method="POST" enctype="multipart/form-data">
<?php
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('../Home'));
$images = new RegexIterator($files, '/\.(?:jpg|png|gif)$/i');
foreach($images as $file)
{
  echo "<div class='images'>\n";
  echo "<img class='thumbNail' id='". htmlspecialchars($images->getFileName()) . "'src='". htmlspecialchars($images->getFileName()) . "' alt='Home Images' />\n ";
  echo "<div class='imagesSelectButton'>\n";
  echo "<input id='imageSelectButton' name='imageSelectButton' type='button' value='Select' />\n";
  echo "</div>\n";
  echo "</div>\n";
}
?>
</form>
4
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by veedeoo
2

you can use submit instead of button. try to analyze this code.

//assume that the file name of this script is test.php
<?php

 if($_POST['submit']=="Test")
 {
    echo "test";
 }

 echo "<form action='test.php' method='post'>";
 echo "<input type='submit' name='submit' value='Test'>";
 echo "</form>";
 
?>
Votes + Comments
well spotted
0

Hi,
Just a humble question from me :)...I thought when using the RecursiveIteratorIterator class goes by this pattern

$the_iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($some_arr));

So, by looking at your codes, I assumed that your are trying to filter the $the_iterator by RegexIterator which is obviously are images.

on your codes, the array is this one

('../Home'

Is it just a place holder?, or this is what you are trying to run with the script?


JUst asking, maybe I can learn something new from this thread :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.