Continuing from my last post(Dynamic PHP), I decided to continue using PHP but use the form-submit way of getting the translation done.
So I changed my script a little, and put it in its own page to display the results and made another page to call it.
I try the page out, it looks like it's going to work, then when I check the source it only shows <html><head>
I have no idea what I did wrong. :S
Here's the translation code:
And here's the calling page:
So I changed my script a little, and put it in its own page to display the results and made another page to call it.
I try the page out, it looks like it's going to work, then when I check the source it only shows <html><head>
I have no idea what I did wrong. :S
Here's the translation code:
Code:
<html>
<head>
<?php
$origString = $_POST['toTrans'];
$placeHolder = 0;
$currentChar = "";
$nextChar = "";
$transString = "";
$checkString = "";
$doublesList = array("ph", "gh", "th", "sh", "ch", "rd", "qu", "ng", "ck");
do {
$currentChar = $origString{$placeHolder};
$nextChar = $origString{$placeHolder + 1};
$checkString = $currentChar + nextChar;
if (in_array($checkString, $doubleList)) {
switch ($checkString) {
case "ph":
$transString += "ng";
break;
case "gh":
$transString += "ng";
break;
case "th":
$transString += "ch";
break;
case "sh":
$transString += "th";
break;
case "ch":
$transString += "sh";
break;
case "rd":
$transString += "ph";
break;
case "qu":
$transString += "ts";
break;
case "ng":
$transString += "rd";
break;
case "ck":
$transString += "k";
break;
$placeHolder += 2;
}
}
else {
switch ($currentChar) {
case "a":
$transString += "i";
break;
case "b":
$transString += "w";
break;
case "c":
$transString += "d";
break;
case "d":
$transString += "p";
break;
case "e":
$transString += "a";
break;
case "f":
$transString += "j";
break;
case "g":
$transString += "l";
break;
case "h":
$transString += "c";
break;
case "i":
$transString += "u";
break;
case "j":
$transString += "f";
break;
case "k":
$transString += "g";
break;
case "l":
$transString += "r";
break;
case "m":
$transString += "t";
break;
case "n":
$transString += "s";
break;
case "o":
$transString += "e";
break;
case "p":
$transString += "b";
break;
case "q":
$transString += "1";
break;
case "r":
$transString += "h";
break;
case "s":
$transString += "m";
break;
case "t":
$transString += "n";
break;
case "u":
$transString += "y";
break;
case "v":
$transString += "z";
break;
case "w":
$transString += "k";
break;
case "x":
$transString += "v";
break;
case "y":
$transString += "o";
break;
case "z":
$transString += "x";
break;
$placeHolder += 1;
}
}
} while ($placeHolder <= strlen($origString));
?>
</head>
<body>
<p>
</p>
</body>
</html>
And here's the calling page:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="dotrans.php">
<textarea name="toTrans"></textarea>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>