0

I want to create a button on a php pafe like a form now after pressing this button i should load an image. Now the I have done this. when the image is appearing it's on the other page than where the button was. I want to have the button on the same page. Left hand side i have a set of buttons and pressing each button should load image on the right side of the same page. I should be able to see the button and image both. Please help me how can I achieve this. Is it possible using only php. ?? Thanks for any help.

<?php

if(isset($_POST['submit']))
{

$imagepath="shirt7.jpg";

$image=imagecreatefromjpeg($imagepath);

header('Content-Type: image/jpeg');

imagejpeg($image);

}
?>
&lt;form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
   &lt;input type="submit" name="submit" value="Submit Form"><br>
&lt;/form>
2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by pritaeas
0

It is possible if, instead of outputting the image, you output an image tag:

if (isset($_POST['submit']))
{
  $imagepath = "shirt7.jpg";
  echo "<img src="$imagepath" />";
}
0

it's giving error.

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in C:\Server\Apache2\htdocs\phpbutton2.php on line 5
0

Now it's coming the '$imagepath' should be single quote. Thanks for your help friend.
echo "<img src='$imagepath' />";

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.