Page 1 of 1
Button to retrieve and display an image?
Posted: Wed Oct 08, 2008 5:03 am
by boondox
Ok what I want is a button that retrieves an image from my server and then displays it on one of my websites pages..
Basically what I want is a way to just push a button that will display a War Alert image on my website
Re: Button to retrieve and display an image?
Posted: Wed Oct 08, 2008 5:20 am
by papa
One way is to use a form and a type=button or type=submit and when the form is submitted you display the image.
if(isset($_POST['button_var'])) echo "<img ...>":
Re: Button to retrieve and display an image?
Posted: Fri Oct 10, 2008 5:07 pm
by boondox
papa wrote:One way is to use a form and a type=button or type=submit and when the form is submitted you display the image.
if(isset($_POST['button_var'])) echo "<img ...>":
this would be helpful IF I knew how to write code...
I need the code already written though then I can just make the changes I need to make to fit it into my page..
Re: Button to retrieve and display an image?
Posted: Fri Oct 10, 2008 5:23 pm
by aceconcepts
There a few ways you could do this. One very simple way would be to create a hidden field with the path and image name (including file type jpg or gif etc...), then create a submit button:
Code: Select all
//This is the form
<form method="post">//this form will POST to itself
<input type="hidden" name="strImage" value="path/image.jpg" />
<input type="submit" name="submitImage" value="Show Image" />
</form>
Code: Select all
//this is the "get image" part
if(isset($_POST['submitImage']))
{
$strImage=$_POST['strImage'];
}
echo'<img src="' . $strImage .'" />';
Does that make sense?