I have got multiple images on my webpage and I am using them as a button and I want to know which image was clicked by a user and post it to another form. I am only concerned with which image was clicked either that is being done by associating any value as a flag to each image and posting it to other form or any other way. Here is link which I found to be relevant but it doesn't work PHP multiple image button submit form. I need a value of the image for further comparison.
and here is my code:
<FORM NAME ="form1" METHOD ="POST" ACTION = "SimulatedOutput.php">
<input type="image" name="rateButton[1]" src="observation1.jpg" width="400" height="300" value="1">T
<input type="image" name="rateButton[2]" src="observation2.jpg" width="400" height="300" value="1">T
<input type="image" name="rateButton[3]" src="observation3.jpg" width="400" height="300" value="1">T
<input type="image" name="rateButton[4]" src="observation4.jpg" width="400" height="300" value="1">T
SimulatedOutput.php
<?php
if ( isset( $_POST['rateButton'] ) ) {
foreach ( $_POST['rateButton'] as $key => $value ) {
echo 'Image number '.$key.' was clicked.';
}
if(name==rateButton[1])
{
//do something as required
}
else if(name==rateButton[2])
{ .....}
}
?>