Thank you in advance for your help! I've been trying to do this for over 12 hours without much luck at all... Please help me figure this VERY SIMPLE little thing out, the current code is sooooooo close to working perfectly and I feel like such a fool, and really have to finish this today somehow! I have a map of the world, with an image map of every single country, and all I want to happen is: IF a user clicks on a country (for example, "USA") THEN an email is sent to me which says "Country: USA" and the user is redirected to a page that says "Thank You" My "Image Map Form" is working 100% perfectly, except that the email I receive has the subject line, but NO CONTENT! How can I make it send me the Country Name? These codes ARE both working in the "area" attributes to successfully SUBMIT the form: href="javascript:document.WorldMapForm.submit();" onClick="WorldMapForm.submit();" These codes AREN'T specifying the Country Name in the EMAIL the above codes send out: onMouseover="document.forms['WorldMapForm'].Country.value='CANADA';" id=Country name=Country value=CANADA I think my mistake may be that I'm specifying the hidden input field incorrectly, but here's how it's specified in the form, right above the image map: <input type="hidden" name="Country" id="Country" runat="server"> PLEAAAAAASE HELP IF YOU CAN
Thank you for the suggestion shofstetter! Just tried it, but it still is just sending a blank email. However, the subject line is correct... Am I doing something wrong with setting up the hidden form inputs?
could you post me your complete code to look at. I will try my best to resolve the issue for you. Usually if it is not being sent it is a typo formatting or other simple error. What are you using to actually send the email php asp other?
Thank you for your help shofstetter! All I want is an email sent with the name of the country specified in the image map area. Here's all the code I'm using (I left in just 2 countries so you see the 2 submit methods that are both successfully sending the email with the right subject line, but its content is blank and doesn't state the value of the Country: <!-- START OF IMAGE MAP FORM--> <FORM method="post" action="securerelay.php" name="WorldMapForm"> <input type="hidden" name="recipients" value="usernamejetSetwebsite.com" /> <input type="hidden" name="mail_options" value="Exclude=email;realname;your_good_url,KeepLines" /> <input type="hidden" name="subject" value="New Country Clicked On Site" /> <input type="hidden" name="good_url" value="http://www.website.com/thankyou.html" /> <input type="hidden" name="Country" id="Country" runat="server"> <img src="images/huge_world_map.jpg" alt="world map" id="world_map" name="world_map" style="border-style:none; align:center fixed;" usemap="#world_image_map"> <br><br> <map id="world_image_map" name="world_image_map"> <area shape=poly alt=Canada onmouseover="this.style.cursor='crosshair'" id=Country name=Country value=CANADA href="javascript:document.WorldMapForm.submit();" onMouseover="document.getElementById('Country').value = 'CANADA';" coords="182,94,217,59,306,39,343,45,373,42,415,28,402,21,425,17,490,9,486,16,449,29,423,45,443,56,45 1,68,429,93,456,150,436,149,422,149,414,159,392,173,391,158,389,148,369,162,330,178,317,155,290,143, 191,146,175,144,182,135,189,132,187,125,196,103,189,102,182,100" title="Canada"> <area shape=poly alt="United States" onmouseover="this.style.cursor='crosshair'" id=Country name=Country value=USA onClick="WorldMapForm.submit();" coords="372,175,346,187,337,207,322,214,314,224,314,248,308,251,303,232,290,224,281,233,264,230,248, 240,246,249,233,232,226,233,219,221,208,223,180,217,164,208,160,185,173,169,180,159,187,150,198,144, 221,144,240,144,267,144,292,144,321,160,326,178,356,167,361,161,374,159,387,150,391,152,392,156,387, 164" title="United States" > </map> </FORM> <!-- END OF IMAGE MAP FORM--> Any ideas about what I'm doing wrong?? All that's left is getting that email to have content.... THANK YOU SO MUCH FOR YOUR HELP!!!
May I see the contents of securerelay.php I don't see any problems with your html form. in the php script you are using the content of your hidden form field will be in a variable like $_POST['Country']; in your php script you can check to see if it is being posted like this: <?php if(isset($_POST['Country'])){ echo $_POST['Country']; }else{ echo "Variable Country was not submitted" } die(); ?> put the code at the very top of the file. If the country form field is recieved it will display the value if not it will give you the message saying it was not sent. This will tell you in which file your problem is. be sure to remove the code after you test it as the die() function stops the scripting engine so you won't be getting an email when you test it. because that will be all the code that gets executed. That is also why you need to place it at the very top of the file:securerelay.php If you do not have access to this file I can write you a simple php email script. I use them all of the time. example: http://automation-repair.com/quoterequest.html posts to mailquote.php which sends me an email a text message to my phone and enters information into my database for processing
hi shofstetter, thank you so much for your help! I tried posting your php script at the top of securerelay.php and when clicking on the image map it said there was an error on line 6. since I'm not an expert at this, i really don't know what that means... the securerelay.php file is at 1822clothing.com/securerelay.php and its made by Tectile FormMail. I've used it on about a dozen websites for various forms, and it always works perfectly even when I introduce new form fields and options without specifying them in the PHP file (the only thing I ever have to change in that file is the email address each form gets sent to) - I've just never tried using it on an image map before, and it's successfully sending the email but without anycontent... Any ideas? your time and advice is REALLY appreciated!!! THANK YOU SO MUCH
sorry forgot to put in a ; at the end of line six. the below should work I have tested it on my server. <?php if(isset($_POST['Country'])){ echo $_POST['Country']; }else{ echo "Variable Country was not submitted"; } die(); ?> Code (markup): perhaps you could also use this to send your email. You will have to customize the variables at the top, but it should work for you. Let me know if you need any changes. <?php $to = "reciepiant@email.to"; //email address to send message to $Subject = "New Country was Clicked"; //Email subject line $body = "Country: ";// Email body the actual country ges appended below $from = "senders@email.address"; //Email address to be sent "From" //Url the user will be directed to after email is sent $thankyou_url = "http://somehwere.com/thankyou.html"; if(isset($_POST['Country'])){ // Check if country wa submitted $country = strip_tags($_POST['Country']); //remove any malicious code if present - never hurts to be safe $body = $body.$country; // append country to body mail($to,$Subject,$body,$from); // send email header( "Location: $thankyou_url" ) ; //redirect user }else{ die("Country not set"); //throw and error id country was not posted } ?> Code (markup): BTW form mail is ok, but it is very configurable(easy to mess up), and the target of many spam exploits.
thank you SOOO MUCH shofstetter for writing that code! i REALLY appreciate it. Could you please advise me on how to implement it (since FormMail IS really easy to mess up...)? Should I post the 2nd longer code into the HTML page between the <form> tags? Or should I put it somewhere into the FormMail PHP file? That file is running 3 forms on the site, and I don't want to accidentally mess up all of them, so your advice is EXTREMELY HELPFUL! Thank you again...!!!
save the second longer code to a file something like mailcounty.php and post your form to it. ex: <form action="mailcountry.php" method="post"> I wrote the script to work with the html form you posted above. just be sure to change to variables $to $from $subject and $thankyou_url to what you need them to be. I put some comments in the code to help you with this.
Okay, PERFECT! Everything is almost working perfectly when I click on Canada, it sends me an email that says "senders@email.address Country: Canada" (Is there any way to remove the whole "senders@email.address" thing, so that it automatically finds out the user's address like FormMail?) I followed your instructions and made the PHP file coded below: <?php $to = "services@website.com"; //email address to send message to $Subject = "New Country Selection From Website.com World Map"; //Email subject line $body = "Country: ";// Email body the actual country ges appended below $from = "senders@email.address"; //Email address to be sent "From" //Url the user will be directed to after email is sent $thankyou_url = "http://www.website.com/thankyou.html"; if(isset($_POST['Country'])){ // Check if country wa submitted $country = strip_tags($_POST['Country']); //remove any malicious code if present - never hurts to be safe $body = $body.$country; // append country to body mail($to,$Subject,$body,$from); // send email header( "Location: $thankyou_url" ) ; //redirect user }else{ die("Country not set"); //throw and error id country was not posted } ?> Code (markup): The only remaining 2 PROBLEMS are that when I click on "USA" it also sends an email that says "senders@email.address Country: Canada" (instead of USA) and when I tried it on a 2nd computer running the same exact version of FireFox, that person's email just reads "senders@email.address Country: " (No country at all shows up, and somehow their message is sent FROM my personal email address which isn't in any of the codes) Here is the Image Map Code that uses the PHP file that you wrote: <!-- START OF WORLD MAP IMAGE MAP FORM--> <FORM method="post" action="securemap.php" name="WorldMapForm"> <input type="hidden" name="recipients" value="servicesjetSetwebsite.com" /> <!--<input type="hidden" name="derive_fields" value="email=EmailAddr,realname=Name" />--> <input type="hidden" name="mail_options" value="Exclude=email;realname;your_good_url,KeepLines" /> <input type="hidden" name="subject" value="New Country Selection From Website.com World Map" /> <input type="hidden" name="good_url" value="http://www.website.com/thankyou.html" /> <input type="hidden" name="Country" id="Country" runat="server"> <img src="images/huge_world_map.jpg" alt="world map" id="world_map" name="world_map" style="border-style:none; align:center fixed;" usemap="#world_image_map"> <br><br> <map id="world_image_map" name="world_image_map"> <area shape=poly alt=Canada id=Canada name=Canada value=Canada onmouseover="this.style.cursor='crosshair'" onclick="document.WorldMapForm.submit();" onClick="document.forms['WorldMapForm'].Country.value= 'Canada';" coords="182,94,217,59,306,39,343,45,373,42,415,28,402,21,425,17,490,9,486,16,449,29,423,45,443,56,451,68,429,93,456,150,436,149,422,149,414,159,392,173,391,158,389,148,369,162,330,178,317,155,290,143,191,146,175,144,182,135,189,132,187,125,196,103,189,102,182,100" title="Canada"> <area shape=poly id=USA name=USA value=USA alt="United States" onmouseover="this.style.cursor='crosshair'" onclick="document.WorldMapForm.submit();" onClick="document.forms['WorldMapForm'].Country.value= 'USA';" coords="372,175,346,187,337,207,322,214,314,224,314,248,308,251,303,232,290,224,281,233,264,230,248,240,246,249,233,232,226,233,219,221,208,223,180,217,164,208,160,185,173,169,180,159,187,150,198,144,221,144,240,144,267,144,292,144,321,160,326,178,356,167,361,161,374,159,387,150,391,152,392,156,387,164" title="United States"> </map> </FORM> <!-- END OF WORLD MAP IMAGE MAP FORM--> Code (markup): Should I remove some of the inputs from the above code, now that the PHP file you made is being used? Or is there an easy way to plug that shorter PHP script you wrote above into FormMail without me messing up FormMail? THANK YOU SO MUCH FOR ALL YOUR HELP SHOFSTETTER!
In your form you have two onclick events for each area one to submit and one to change the value of country. When you click on it. It is submitting the form before changing the value of country. Try making it change the value of country using onmouseover instead like this: <!-- START OF WORLD MAP IMAGE MAP FORM--> <FORM method="post" action="securemap.php" name="WorldMapForm"> <input type="hidden" name="recipients" value="servicesjetSetwebsite.com" /> <!--<input type="hidden" name="derive_fields" value="email=EmailAddr,realname=Name" />--> <input type="hidden" name="mail_options" value="Exclude=email;realname;your_good_url,KeepLines" /> <input type="hidden" name="subject" value="New Country Selection From Website.com World Map" /> <input type="hidden" name="good_url" value="http://www.website.com/thankyou.html" /> <input type="hidden" name="Country" id="Country" runat="server"> <img src="images/huge_world_map.jpg" alt="world map" id="world_map" name="world_map" style="border-style:none; align:center fixed;" usemap="#world_image_map"> <br><br> <map id="world_image_map" name="world_image_map"> <area shape=poly alt=Canada id=Canada name=Canada value=Canada onmouseover="this.style.cursor='crosshair';document.forms['WorldMapForm'].Country.value= 'Canada';" onclick="document.WorldMapForm.submit();" coords="182,94,217,59,306,39,343,45,373,42,415,28,402,21,425,17,490,9,486,16,449,29,423,45,443,56,451,68,429,93,456,150,436,149,422,149,414,159,392,173,391,158,389,148,369,162,330,178,317,155,290,143,191,146,175,144,182,135,189,132,187,125,196,103,189,102,182,100" title="Canada"> <area shape=poly id=USA name=USA value=USA alt="United States" onmouseover="this.style.cursor='crosshair';document.forms['WorldMapForm'].Country.value= 'USA';" onclick="document.WorldMapForm.submit();" coords="372,175,346,187,337,207,322,214,314,224,314,248,308,251,303,232,290,224,281,233,264,230,248,240,246,249,233,232,226,233,219,221,208,223,180,217,164,208,160,185,173,169,180,159,187,150,198,144,221,144,240,144,267,144,292,144,321,160,326,178,356,167,361,161,374,159,387,150,391,152,392,156,387,164" title="United States"> </map> </FORM> <!-- END OF WORLD MAP IMAGE MAP FORM--> Code (markup): And to get the users email address you will have to ask for it in your form so it can be sent to the php script. something like this: <b>Your Email address</b><input type="text" name="user_email" id="user_email"> Code (markup): the php script can then be modified to use it like this: <?php $to = "services@website.com"; //email address to send message to $Subject = "New Country Selection From Website.com World Map"; //Email subject line $body = "Country: ";// Email body the actual country ges appended below if(isset($_POST['user_email'])){ // check to see if user_email was posted if(isEmail($_POST['user_email']){ //check to see if posted data is a valid email address $from = $_POST['user_email']; //if it was posted and is valid we will set our from address to the posted address } }else{ // if there was no email address posted lets use a "default" from address $from = "service@website.com"; //this means if no email address is submited the email will be sent from you to you. } //Url the user will be directed to after email is sent $thankyou_url = "http://www.website.com/thankyou.html"; if(isset($_POST['Country'])){ // Check if country wa submitted $country = strip_tags($_POST['Country']); //remove any malicious code if present - never hurts to be safe $body = $body.$country; // append country to body mail($to,$Subject,$body,$from); // send email header( "Location: $thankyou_url" ) ; //redirect user }else{ die("Country not set"); //throw and error id country was not posted } // a function to check if the email address entered is a valid email address function isEmail($email){ return preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email) ? TRUE : FALSE; } ?> Code (markup):
Check THIS out: A user named "birdbrain" on WebmasterWorld.com sent us an even faster, simpler & easier solution to the whole original question: We just tested it, and simply adding it into the original image map codes is working perfectly! Thank you shofstetter for all your help in finding the answer to this question, that after a week of research, it seems dozens if not thousands of people are looking for.