I am having issues trying to access a submitted image from a form on the next page.
Here is my php in my html.
I am looping through a folder of images and echoing them onto the page.
<form action = "Order_Form.php"
method = "post"
enctype = "multipart/form-data">
<?php
$files = glob("images/*.*");
$count = 0;
for ($i=0; $i<count($files); $i++)
{
$num = $files[$i];
if($count == 4){
echo "<br>";
$count = 0;
}
$count++;
echo '<input type="image" src="'.$num.'"
alt="img" name="image" class = "galImgs" value="submit" />';
}
?>
</form>
And now on submit I proceed to Order_Form.php
I want to display the picture the user clicked/submitted to the page.
I have been trying with
$nm = $_POST['image'];
echo '<img src="/files/images/.$nm" class= "image"/>';
Im pretty sure it has to be something simple, but after much googling and trial & error I can’t seem to figure this out.
Any help would be appreciated. Thank you.
The value of your button will be that of it’s
valueattribute, or alwaysSubmit.Use an array of images in the
$_POSTby appending[$num]to the inputnameattribute.This will send the input
imageto$_POSTas an array which looks likeThen when you retrieve it from
$_POST, you know which has been clicked: