Jump to content

trying to learn how to submit a form via an image map, and check POST with php


silverglade

Recommended Posts

hi, I've looked all over the net for solutions and none of the Javascript code snippets they said to add to the image map worked. I am trying to have an image map submit an empty form , and then I check if POSTED with PHP, and if it is posted, I output to the page, "cool it worked". Eventually this is going to be used to change images within a div when the user clicks on an image map it will change to the next image, linked image maps within a div. Not sure if that makes sense. Lol. Ok thanks, any help greatly appreciated. Derek

 

I tried this so far.

 

<?php
if(!empty($_POST['mapform']))
{
echo "it worked!";

}




?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form action='aradia.php' method='post' name='mapform'>
  
<img src="aradia.jpg" width="256" height="328" border="0" usemap="#Map" />
<map name="Map" id="Map"><area shape="rect" coords="5,176,81,249" href="javascript:;" onClick="document.mapform.submit()"
/></map>



</form>

</body>
</html>

Link to comment
Share on other sites

Try it like this:

 

<form action="aradia.php" method="post" name="mapform" id="mapform">
   <img src="aradia.jpg" width="256" height="328" border="0" usemap="#Map" />
</form>

<map name="Map" id="Map">
   <area shape="rect" coords="5,176,81,249" href="javascript: void(0);" onclick="javascript: document.getElementById('mapform').submit()" />
</map>

Link to comment
Share on other sites

Thanks for writing that. I tried it but it doesn't work for me. Here is the code I used for the page. Any more help greatly appreciated!

 

<?php
if(!empty($_POST['mapform']))
{
echo "it worked !";

}




?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="aradia.php" method="post" name="mapform" id="mapform">
   <img src="aradia.jpg" width="256" height="328" border="0" usemap="#Map" />
</form>

<map name="Map" id="Map">
   <area shape="rect" coords="5,176,81,249" href="javascript: void(0);" onclick="javascript: document.getElementById('mapform').submit();" />
</map>

</body>
</html>

Link to comment
Share on other sites

Yeah sorry, the code is right. It's just you're going about it wrong. You'll need a hidden value, because really no post data is being sent because there is nothing to send.

 

Place this just before the closing form tag:

 

<input type="hidden" name="checker" value="checked" />

 

Then your PHP code should be:

 

if(isset($_POST['checker']) && $_POST['checker'] == 'checked')
{
   echo "it worked !";
   
}

Link to comment
Share on other sites

HOLY COW PROJECT FEAR!! HAHHAHAHAHA. IT WORKS!! oh man, you're the best, I've been trying to find a solution for that on the net and google for like 12 hours straight and no sleep. Thank GOD I can freakin go to sleep now thanks to you. HAHA! THanks Project Fear. Derek :D :D :D :D :D :D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.