vigiw Posted January 15, 2007 Share Posted January 15, 2007 Hello, I have a PHP form that submits its data to MySQL. It is already functioning properly and doing what I want it to. However, for one of the text fields, I would like to have an image map in the page that is "clickable" on its different parts--and the different parts of the map will input different text outputs.For example, If it is a map of Massachusetts, I may have An hotspot on the west which will output 'Western Massachusetts' or same with Eastern, or both at the same time.Is there any way to make this output the text desired from a map to the form field--rather than linking to something, it will output text to a field?This is a necessity for my website, and any help is certainly appreciated!Thanks. Link to comment https://forums.phpfreaks.com/topic/34301-image-map-text-output-in-form/ Share on other sites More sharing options...
vigiw Posted January 16, 2007 Author Share Posted January 16, 2007 Ok, I have some code that is working--somewhat.I have added--[code]<MAP NAME=mymap><area href="submit.php?hampden=selected<?php if($_GET['hampden']) echo "&hampden=" . $_GET['hampden'] ?>" ALT="Hampden County" shape="polygon" coords="125, 199, 168, 201, 167, 205, 176, 209, 181, 200, 216, 203, 287, 202, 295, 201, 295, 174, 286, 171, 280, 167, 274, 165, 274, 156, 264, 153, 257, 158, 255, 162, 249, 161, 246, 155, 211, 156, 207, 153, 209, 142, 206, 143, 202, 148, 197, 155, 192, 163, 179, 160, 174, 153, 165, 155, 158, 149, 155, 149, 156, 131, 153, 124, 139, 131, 136, 136, 131, 168, 123, 174"><area href="submit.php?berkshire=selected<?php if($_GET['berkshire']) echo "&berkshire=" . $_GET['berkshire'] ?>" ALT="Berkshire County" coords="42, 196, 125, 200, 123, 175, 131, 170, 136, 135, 131, 132, 126, 128, 126, 115, 136, 118, 138, 94, 148, 28, 90, 25, 85, 30, 54, 131, 51, 145, 44, 175" shape=polygon><area href="submit.php?hampshire=selected<?php if($_GET['hampden']) echo "&hampshire=" . $_GET['hampshire'] ?>" shape="polygon" coords="140, 75, 158, 78, 162, 91, 183, 98, 186, 98, 190, 98, 191, 107, 200, 109, 224, 105, 234, 108, 249, 108, 269, 123, 271, 135, 278, 135, 280, 146, 277, 154, 274, 155, 264, 153, 253, 161, 249, 161, 245, 156, 205, 155, 208, 143, 192, 161, 178, 162, 172, 152, 166, 153, 156, 145, 155, 127, 152, 125, 136, 134, 126, 126, 127, 116, 132, 118, 133, 118, 138, 102"><area href="submit.php?franklin=selected<?php if($_GET['franklin']) echo "&franklin=" . $_GET['franklin'] ?>" shape="polygon" coords="257, 114, 268, 92, 274, 80, 271, 71, 272, 61, 279, 51, 270, 43, 268, 33, 266, 30, 148, 30, 141, 76, 156, 77, 167, 93, 188, 99, 189, 100, 192, 108, 226, 105, 249, 109"><area href="submit.php?worcester=selected<?php if($_GET['worcester']) echo "&worcester=" . $_GET['worcester'] ?>" shape="polygon" coords="294, 202, 364, 207, 414, 205, 413, 171, 396, 159, 392, 154, 400, 146, 409, 142, 413, 133, 409, 129, 397, 127, 395, 129, 392, 122, 404, 104, 405, 80, 397, 74, 380, 82, 381, 74, 381, 67, 373, 55, 362, 50, 343, 54, 348, 40, 342, 37, 266, 30, 272, 42, 278, 52, 271, 66, 272, 80, 266, 95, 259, 114, 269, 121, 271, 136, 276, 136, 280, 137, 278, 152, 272, 160, 283, 173, 294, 174, 295, 184"><area href="submit.php?litchfield=selected<?php if($_GET['litchfield']) echo "&litchfield=" . $_GET['litchfield'] ?>" shape="polygon" coords="42, 197, 39, 295, 57, 332, 105, 331, 124, 311, 139, 302, 142, 289, 132, 276, 132, 265, 134, 259, 151, 259, 145, 255, 145, 250, 145, 240, 148, 236, 156, 218, 133, 218, 136, 200"><area href="submit.php?hartford=selected<?php if($_GET['hartford']) echo "&hartford=" . $_GET['hartford'] ?>" shape="polygon" coords="141, 297, 149, 317, 169, 318, 199, 307, 223, 304, 239, 307, 243, 304, 236, 291, 229, 252, 228, 247, 223, 240, 226, 203, 182, 201, 175, 209, 167, 205, 165, 200, 136, 200, 134, 215, 155, 219, 145, 243, 147, 255, 149, 258, 133, 261, 132, 276, 139, 288"><area href="submit.php?tolland=selected<?php if($_GET['tolland']) echo "&tolland=" . $_GET['tolland'] ?>" shape="polygon" coords="227, 205, 227, 222, 225, 235, 226, 243, 241, 308, 254, 306, 260, 298, 275, 280, 279, 275, 288, 264, 286, 255, 282, 249, 281, 221, 297, 221, 305, 204, 283, 201"><area href="submit.php?windham=selected<?php if($_GET['windham']) echo "&windham=" . $_GET['windham'] ?>" shape="polygon" coords="273, 281, 304, 303, 357, 295, 355, 207, 306, 204, 297, 222, 282, 219, 282, 249, 287, 262"></MAP><IMG SRC="http://www.vigilantweather.com/forecast/maps/sfd.jpg" ALT="Site map" USEMAP="#mymap" WIDTH=445 HEIGHT=457><?phpif($_GET['hampden'] == "selected") echo "Hampden, ";if($_GET['berkshire'] == "selected") echo "Berkshire, ";if($_GET['hampshire'] == "selected") echo "Hampshire, ";if($_GET['franklin'] == "selected") echo "Franklin, ";if($_GET['worcester'] == "selected") echo "Worcester, ";if($_GET['litchfield'] == "selected") echo "Litchfield, ";if($_GET['hartford'] == "selected") echo "Hartford, ";if($_GET['tolland'] == "selected") echo "Tolland, ";if($_GET['windham'] == "selected") echo "Windham, ";?>[/code]To the top of my PHP form page--here's the full code with the addition on the page:[code]<MAP NAME=mymap><area href="submit.php?hampden=selected<?php if($_GET['hampden']) echo "&hampden=" . $_GET['hampden'] ?>" ALT="Hampden County" shape="polygon" coords="125, 199, 168, 201, 167, 205, 176, 209, 181, 200, 216, 203, 287, 202, 295, 201, 295, 174, 286, 171, 280, 167, 274, 165, 274, 156, 264, 153, 257, 158, 255, 162, 249, 161, 246, 155, 211, 156, 207, 153, 209, 142, 206, 143, 202, 148, 197, 155, 192, 163, 179, 160, 174, 153, 165, 155, 158, 149, 155, 149, 156, 131, 153, 124, 139, 131, 136, 136, 131, 168, 123, 174"><area href="submit.php?berkshire=selected<?php if($_GET['berkshire']) echo "&berkshire=" . $_GET['berkshire'] ?>" ALT="Berkshire County" coords="42, 196, 125, 200, 123, 175, 131, 170, 136, 135, 131, 132, 126, 128, 126, 115, 136, 118, 138, 94, 148, 28, 90, 25, 85, 30, 54, 131, 51, 145, 44, 175" shape=polygon><area href="submit.php?hampshire=selected<?php if($_GET['hampden']) echo "&hampshire=" . $_GET['hampshire'] ?>" shape="polygon" coords="140, 75, 158, 78, 162, 91, 183, 98, 186, 98, 190, 98, 191, 107, 200, 109, 224, 105, 234, 108, 249, 108, 269, 123, 271, 135, 278, 135, 280, 146, 277, 154, 274, 155, 264, 153, 253, 161, 249, 161, 245, 156, 205, 155, 208, 143, 192, 161, 178, 162, 172, 152, 166, 153, 156, 145, 155, 127, 152, 125, 136, 134, 126, 126, 127, 116, 132, 118, 133, 118, 138, 102"><area href="submit.php?franklin=selected<?php if($_GET['franklin']) echo "&franklin=" . $_GET['franklin'] ?>" shape="polygon" coords="257, 114, 268, 92, 274, 80, 271, 71, 272, 61, 279, 51, 270, 43, 268, 33, 266, 30, 148, 30, 141, 76, 156, 77, 167, 93, 188, 99, 189, 100, 192, 108, 226, 105, 249, 109"><area href="submit.php?worcester=selected<?php if($_GET['worcester']) echo "&worcester=" . $_GET['worcester'] ?>" shape="polygon" coords="294, 202, 364, 207, 414, 205, 413, 171, 396, 159, 392, 154, 400, 146, 409, 142, 413, 133, 409, 129, 397, 127, 395, 129, 392, 122, 404, 104, 405, 80, 397, 74, 380, 82, 381, 74, 381, 67, 373, 55, 362, 50, 343, 54, 348, 40, 342, 37, 266, 30, 272, 42, 278, 52, 271, 66, 272, 80, 266, 95, 259, 114, 269, 121, 271, 136, 276, 136, 280, 137, 278, 152, 272, 160, 283, 173, 294, 174, 295, 184"><area href="submit.php?litchfield=selected<?php if($_GET['litchfield']) echo "&litchfield=" . $_GET['litchfield'] ?>" shape="polygon" coords="42, 197, 39, 295, 57, 332, 105, 331, 124, 311, 139, 302, 142, 289, 132, 276, 132, 265, 134, 259, 151, 259, 145, 255, 145, 250, 145, 240, 148, 236, 156, 218, 133, 218, 136, 200"><area href="submit.php?hartford=selected<?php if($_GET['hartford']) echo "&hartford=" . $_GET['hartford'] ?>" shape="polygon" coords="141, 297, 149, 317, 169, 318, 199, 307, 223, 304, 239, 307, 243, 304, 236, 291, 229, 252, 228, 247, 223, 240, 226, 203, 182, 201, 175, 209, 167, 205, 165, 200, 136, 200, 134, 215, 155, 219, 145, 243, 147, 255, 149, 258, 133, 261, 132, 276, 139, 288"><area href="submit.php?tolland=selected<?php if($_GET['tolland']) echo "&tolland=" . $_GET['tolland'] ?>" shape="polygon" coords="227, 205, 227, 222, 225, 235, 226, 243, 241, 308, 254, 306, 260, 298, 275, 280, 279, 275, 288, 264, 286, 255, 282, 249, 281, 221, 297, 221, 305, 204, 283, 201"><area href="submit.php?windham=selected<?php if($_GET['windham']) echo "&windham=" . $_GET['windham'] ?>" shape="polygon" coords="273, 281, 304, 303, 357, 295, 355, 207, 306, 204, 297, 222, 282, 219, 282, 249, 287, 262"></MAP><IMG SRC="http://www.vigilantweather.com/forecast/maps/sfd.jpg" ALT="Site map" USEMAP="#mymap" WIDTH=445 HEIGHT=457><?phpif($_GET['hampden'] == "selected") echo "Hampden, ";if($_GET['berkshire'] == "selected") echo "Berkshire, ";if($_GET['hampshire'] == "selected") echo "Hampshire, ";if($_GET['franklin'] == "selected") echo "Franklin, ";if($_GET['worcester'] == "selected") echo "Worcester, ";if($_GET['litchfield'] == "selected") echo "Litchfield, ";if($_GET['hartford'] == "selected") echo "Hartford, ";if($_GET['tolland'] == "selected") echo "Tolland, ";if($_GET['windham'] == "selected") echo "Windham, ";?><?include("db.php");$field1 = $_POST['field1'];$field2 = $_POST['field2'];$field3 = $_POST['field3'];$field4 = $_POST['field4'];$field5 = $_POST['field5'];strtotime("+ " . $_POST['field5'] . " hours " . $_POST['minutes'] . "minutes");$field5 = date("Y-m-d G:i:s", strtotime("+ " . $_POST['field5'] . " hours " . $_POST['minutes'] . "minutes"));if($_POST['sub'] == "yes") {}if($_GET['success'] != "yes") { ?><form action="submit.php" method=POST><font size="2" face="Arial">Alert Type: </font><font face="Arial"> <input type="text" name="field1" <? if(isset($field1)) { echo "value=\"" . $field1 . "\""; } ?>><font size="2"> Choices: Severe Thunderstorm Watch -or- Severe Thunderstorm Watch Update -or- Severe Thunderstorm Watch Correction (Use choice 1 if it is just a normal Severe Thunderstorm Watch issuance; use choice 2 if it is an update from an earlier Severe Thunderstorm Watch; </font></font><font size="2" face="Arial">use choice 3 if you are correcting a Severe Thunderstorm Watch that you issued earlier)</font><p><font face="Arial" size="2">Counties: </font><font face="Arial"> <textarea name="field4" rows="9" cols="78"></textarea><font size="2">List the counties here and separate by state and comma. Example: In Massachusetts: Bristol, Plymouth, and Barnstable counties. In Rhode Island: Providence county.</font></font></p><p><font face="Arial" size="2">Expires (Hours): <input type="text" name="field5" <? if(isset($field1)) { echo "value=\"" . $field5 . "\""; } ?>>Format: 6 ***JUST TYPE IN THE NUMBER! DO NOT INCLUDE "HOURS", JUST THE NUMBER! This number will be the number of hours (and minutes, see below) after issuance that this alert will expire. Example: If it is 6:00am Eastern Time, and you type "6" (without quotes), the alert will expire at 12:00pm Eastern Time.</font><br><font face="Arial" size="2">Expires (Minutes): <input type="text" name="minutes" <? if(isset($minutes)) { echo "value=\"" . $field5 . "\""; } ?>>Format: 20 ***JUST TYPE IN THE NUMBER! DO NOT INCLUDE "MINUTES", JUST THE NUMBER! This number will be the number of minutes (and hours, see above) after issuance that this alert will expire. Example: If it is 6:00am Eastern Time, and you type "6" (without quotes), the alert will expire at 12:00pm Eastern Time.</font></p><p><font face="Arial" size="2">Alert Text: </font><font face="Arial"> <font size="2"> <textarea name="field2" rows="9" cols="78">Type in the alert, detailed, here.</textarea></font><font size="2" face="Arial"><BR>Forecaster: </font> <input type="text" name="field3" <? if(isset($field3)) { echo "value=\"" . $field3 . "\""; } ?>><font size="2"> (Your first and last name)</font><font size="2" face="Arial"><BR></font><font face="Arial"><input type="hidden" name="sub" value="yes"><input type="submit" value="Send"></font></p><p>**KEEP IN MIND: Severe Thunderstorm Watches are not official alerts issued by NOAA! Also, we issue these only as needed. Be conservative, as with all other alerts issued via VWFN.<font size="2" face="Arial"> </font></p><p><span style="font-style: italic; text-decoration: underline; background-color: #FF0000"><a href="http://www.vigilantweather.com/forecast/alerts.html"><font color="#FFFFFF">VERY IMPORTANT -- BOOKMARK:</font></a></span></p><p><font color="#000080"><span style="font-weight: 700; background-color: #00FFFF"><a href="http://www.vigilantweather.com/forecast/alerts.html">REFERENCE: Go to the VWFN Weather Alerts page to view the official VWFN weather alert definitions. This will greatly help forecasters! Do not skip, this is an important step and will improve upon your forecasting for VWFN. Technical definitions; take notes, bookmark!</a></span></font></p></form><?}/* note: .= defines a variable or adds onto it if it already exists... for example$var1 = "hello";$var1 .= " my name is corbin";echo $var1;would out put hello my name is corbin*/if(isset($error)) {echo "There was one or more error!<BR>";echo $error;}else {if(($_GET['success'] != "yes") && ($_POST['sub'] == "yes")) { // checks to see if $error is set of if the GET variable of success does not equal yes$field1 = htmlspecialchars($field1);// if $field does not return an error it replaces any thing that could be interpetted as a browser as html$field2 = htmlspecialchars($field2);$field3 = htmlspecialchars($field3);$field4 = htmlspecialchars($field4);$field5 = htmlspecialchars($field5);$q = mysql_query("INSERT INTO `" . $table_name . "` (`field1` , `field2` , `field3`, `field4`, `field5`) VALUES ('" . $field1 . "', '" . $field2 . "', '" . $field3 ."', '" . $field4 . "', '" . $field5 . "')");if($q) { //what to do if the mysql query is successful $error = NULL;?><meta http-equiv="refresh" content="0;url=<? echo $_SERVER['HTTP_SELF'] . "?success=yes"; ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>" ?>"><?//by forwarding to its self the page will clear its post values so if a user hits refresh its not inserted into the database again...} //the meta tag has it forward it to this page cept with the $_GET['success'] tag set}elseif($_GET['success'] == "yes") { //what to do if $_GET['success'] does equal yesecho "Severe Thunderstorm Watch successfully issued.";}}mysql_close(); //closes the link to mysql}?>[/code]Is there a way to make those counties go to form field4 and add up and not be removed each time a county is selected. So far, when I click a county, it is displayed next to the image, not in the form field, and when I select a new one, the page refreshes or something because my last county is removed and replaced with the new one.Any help is really appreciated. I would very much like to have this on my website, it would be a great help for volunteer forecasters.Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/34301-image-map-text-output-in-form/#findComment-161725 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.