Find a points distance from the origin.
Please enter an X & Y axis!
Source Code
<form action="path.php" method="post" name="path" id="path">
<table width="335" border="0" cellpadding="4" cellspacing="0" class="underline">
<tr class="underline">
<td width="165">Enter the points X-Axis</td>
<td width="162"><input name="x" type="text" id="x" size="15" maxlength="6"></td>
</tr>
<tr class="underline">
<td>Enter the points Y-Axis </td>
<td><input name="y" type="text" id="y" size="15" maxlength="6"></td>
</tr>
<tr class="underline">
<td>Precision</td>
<td><select name="precision" id="precision">
<option value="0">Zero Decimals</option>
<option value="1">One Decimal</option>
<option value="2">Two Decimals</option>
<option value="3">Three Decimals</option>
<option value="4">Four Decimals</option>
<option value="5">Five Decimals</option>
<option value="6">Six Decimals</option>
<option value="7">Seven Decimals</option>
<option value="8">Eight Decimals</option>
<option value="9">Nine Decimals</option>
<option value="10">Ten Decimals</option>
</select></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="Find the Distance!"></td>
</tr>
</table>
</form>
<p>
<?
$x = $_POST['x'];
$y = $_POST['y'];
$pre = $_POST['precision'];
if($x!='' && $y!='')
{
// using pathagorams theorum, find the distance from the origin.
$answer = (($x*$x) + ($y*$y));
$answer = sqrt($answer);
$answer = round($answer, $pre);
echo("<h3>Distance from point (".$x.",".$y.") to (0,0) is <font color=\"red\">".$answer."</font></h3>");
}else
{
echo("Please enter an X & Y axis!");
}
?>
</p>