Save variable $ _POST when clicking on an image

0

I have the following loop that displays the folders that are in a default location.

 while ($fil = readdir($carpeta)) {
        if (is_dir($ruta . $fil) && $fil != "." && $fil != "..") {
            echo "<div class='col-md-4 col-sm-6 col-xs-6 col-xxs-12 work-item'>";
            echo "<a href='/BotigaVirtual/codiFont/vistaFotosAlbum.php/?album=" . $this->ruta . $fil . "'> <img src='../codiFont/images/fotoAlbum.jpg'";
            echo "class='img-responsive' class='fh5co-work-title'>";
            echo "<h4>" . $fil . "</h4>";
            echo "</a>";
            echo "</div>";
        }
    }

I need to do that by clicking on the photo of the location, go to another page and pass them a parameter of $ _POST [] to be able to print it on that screen. I've tried it with $ _GET but I'd like to do it more with $ _POST.

Thank you very much for the help.

    
asked by Martí Font 16.11.2018 в 19:25
source

1 answer

0

The example of the link is in case you have to select and then send the form, so that the submission is by clicking on the image you can use buttons without styles, something like this:

<?php
$ruta = __DIR__. '/images/';
$carpeta = opendir($ruta);
?>
<form action="vistaFotosAlbum.php" method="post">
  <?php
  while ($fil = readdir($carpeta)) :
    if (is_dir($ruta . $fil) && $fil != "." && $fil != "..") :
      ?>
      <div class="col-md-4 col-sm-6 col-xs-6 col-xxs-12 work-item">
        <button
          name="album"
          value="<?php echo $ruta . $fil ?>"
          style="background:none;border:medium none;cursor:pointer;"
        >
        <img
        src="http://icons.iconarchive.com/icons/janosch500/tropical-waters-folders/256/Applications-icon.png"
        class="img-responsive fh5co-work-title"
        width="32" height="32"
        >
        <h4><?php echo $fil;?></h4>
      </button>
    </div>
    <?php
  endif;
endwhile;
?>
</form>
    
answered by 20.11.2018 / 23:00
source