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>

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>";
 
?>
commented: well spotted +14
commented: Yes +7

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.