I'm writing a script for an mmorpg game that deals with having a set of choords that tell you pin-point locations on the world map. I need to take a string and break it down into 4 parts, then have php read it as one equal string (in order). As an example, the string "0013s1313e" would break down like this;
00 Degress 13minutes South
13 Degress 13minutes East
When the user enters the 4 parts in this form below as 00, 13, 13, 13 and hit submit, I'd like to load the definition and image for that set of choords using a php page in the example below. (choords.php?choords=0013s1313e) There are literally hundreds of the if statments, that'll have it's own file.
<form name="choord" action="load.php" method="get">
<input type="hidden" name="id" value="choords">
<input type="text" name="d1" size="20" maxlength="12">
<input type="text" name="loc1" size="20" maxlength="12">
<input type="text" name="d2" size="20" maxlength="12">
<input type="text" name="loc2" size="20" maxlength="12">
<input type="submit" value="Find Choord"></form>
<?php
$choord = $_GET['choord']; {
if ($choord = "0013s1313e") { print "Definition of the matching choord.\n"; }
}
?>
My problem is I don't know how to go about breaking down '0013s1313e' and then having it put together again. I also thought about using a form validation javascript to redirect the user, but I still have the same issue to deal with and rather do it in php.
function valid(form) {
var field = form.choord;
var choord = field.value;
if (choord == "0013s1313e") {
alert("Definition of the matching choord.");
return false;
} else {
alert("Sorry, I could not find that location.");
field.focus();
field.select();
return false;
}
}
Could anyone give me any adivce on how to go about this, a point in the right direction would be great. Thanks a head of time.