Reputation: 255
So I have this html code for an image:
<a href"hurr.php" onclick="post"><img src="images/img1.png"/></a>
I also have other images on the same page that also link to hurr.php. What I want to do is for hurr.php to be a custom page that displays information based on which image was clicked to get to the page. So, for example, I would use the php echo function to display img1.png rather than img2.png.
Is the code I have for the image right, and what code do I need to display on hurr.php in order to display custom information on each image? I want to use 'post' for this.
Upvotes: 1
Views: 3452
Reputation: 3538
There is two way of doing this, if you have to use POST variable then you need to use AJAX, or you can send the GET variable.
<a href="hurr.php?myVar=someValue" onclick="post"><img src="images/img1.png"/></a>
In hurr.php
you can get the variable by either $_GET['myVar']
or $_REQUEST['myVar']
Upvotes: 2
Reputation: 1013
<a href="#" onclick="document.form_name.image_name.value = 'img1.png'; document.form_name.submit(); return false;"><img src="images/img1.png"/></a>
<form id="form_name" name="form_name" action="hurr.php" method="post">
<input type="hidden" id="image_name" name="image_name" value="" />
</form>
Upvotes: 3