Jump to content

Image Hotspot using PHP


nutt318

Recommended Posts

The below code works with only one mapping for a button. When I add the second map for another Hotspot on the same image it executes both PHP scripts. Is there something that I have out of place?

 

Just need some help getting this thing to work right.

 

Thanks.

 

<body>
<img src="control.png" width="600" height="350" border="0" usemap="#Map"  />

<map name="Map" id="Map">
<area shape="rect" coords="42,9,104,30" href="#" onclick="javascript:document.frm1.submit();"  /> 
	<area shape="rect" coords="6,35,68,56" href="#" onclick="javascript:document.frm2.submit();"  />
</map>

<?php
if($_POST['Submit']){
   $open = fopen("commands.dat","a+");
   $text = "81\n";
   fwrite($open, $text);
   fclose($open);
}
echo "<form name='frm1' action=\"".$_SERVER['http://mysite.com/wordpress/control.php']."\" method=\"post\">";
echo "<input name=\"Submit\" type=\"hidden\" value=\"Submit\" />\n
</form>";
?>


<?php
if($_POST['Submit']){
   $open = fopen("commands.dat","a+");
   $text = "82\n";
   fwrite($open, $text);
   fclose($open);
}
echo "<form name='frm2' action=\"".$_SERVER['http://mysite.com/wordpress/control.php']."\" method=\"post\">";
echo "<input name=\"Submit\" type=\"hidden\" value=\"Submit\" />\n
</form>";
?>



</body>

Link to comment
https://forums.phpfreaks.com/topic/145084-image-hotspot-using-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.