Location: PHPKode > scripts > Wap Calculator > wap-calculator/calc.php
<?php
/////////////////////////////////////////////////////////
/////////////Abhi calc v1.0///////////////////////
/////Mailto:hide@address.com/////////
////////////////////////////////////////////////////////
header("Content-type: text/vnd.wap.wml");
echo "<?xml version=\"1.0\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""
   . " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
?>
<wml>
<?php
if ($action=="")  {
echo "<card id=\"card1\" title=\"Calculator\">";
echo "<p>";
echo "<b>Calculator</b><br/>";
echo "Enter Value:<br/>";
echo "<input emptyok=\"true\" name=\"no\"  format=\"*n\" maxlength=\"255\" size=\"4\"/>";
echo "<small>";
echo "<br/><anchor title=\"Square Root\">Square Root";
echo "<go href=\"calc.php?action=sqrt\" method=\"post\">";
echo "<postfield name=\"no\" value=\"\$no\"/>";
echo "</go>";
echo "</anchor>";
echo "<br/><anchor title=\"Cosine\">Cosine";
echo "<go href=\"calc.php?action=cosine\" method=\"post\">";
echo "<postfield name=\"no\" value=\"\$no\"/>";
echo "</go>";
echo "</anchor>";
echo "<br/><anchor title=\"Sine\">Sine";
echo "<go href=\"calc.php?action=sine\" method=\"post\">";
echo "<postfield name=\"no\" value=\"\$no\"/>";
echo "</go>";
echo "</anchor>";
echo "<br/><anchor title=\"Tangent\">Tangent";
echo "<go href=\"calc.php?action=tangent\" method=\"post\">";
echo "<postfield name=\"no\" value=\"\$no\"/>";
echo "</go>";
echo "</anchor>";
echo "<br/><b>Other Calcs:</b><br/>";
echo "<a href=\"calc.php?action=areacalc\">Area Calculator</a><br/>";
echo "<a href=\"calc.php?action=hypotcalc\">Hypotenuse Calculator</a>";
echo "</small>";
echo "<br/><b><small>&#169; Scripted BY Abhisar</small></b>";
echo "</p>";
echo "</card>"; }

///////////////////////////////Square Root//////////////////
if ($action=="sqrt") {
$no=$_POST["no"];
echo "<card id=\"card1\" title=\"Calculator\">";
echo "Square Root of $no is ";
echo sqrt($no);
echo "</card>"; }

///////////////////////////////Cosine//////////////////
if ($action=="cosine") {
$no=$_POST["no"];
echo "<card id=\"card1\" title=\"Calculator\">";
echo "Cosine of $no is ";
echo cos($no);
echo "</card>"; }

///////////////////////////////Sine////////////////////
if ($action=="sine") {
$no=$_POST["no"];
echo "<card id=\"card1\" title=\"Calculator\">";
echo "Sine of $no is ";
echo sin($no);
echo "</card>"; }

/////////////////////////////Tangent/////////////////////
if ($action=="tangent") {
$no=$_POST["no"];
echo "<card id=\"card1\" title=\"Calculator\">";
echo "Tangent of $no is ";
echo tan($no);
echo "</card>"; }

///////////////////////////Area Calcs////////////////////
if ($action=="areacalc") {
echo "<card id=\"card1\" title=\"Area Calc\">";
echo "<p>";
echo "<a href=\"calc.php?action=squarearea\">Square</a><br/>";
echo "<a href=\"calc.php?action=rectanglearea\">Rectangle</a><br/>";
echo "</p>";
echo "</card>"; }

/////////////////////////Square area//////////////////
if ($action=="squarearea") {
echo "<card id=\"card1\" title=\"Area Calc\">";
echo "<p>";
echo "<b>Enter side:</b><br/><input emptyok=\"true\" name=\"sqside\" format=\"*n\"/><br/>";
echo "<anchor title=\"Go\">Go";
echo "<go href=\"calc.php?action=squarearea2\" method=\"post\">";
echo "<postfield name=\"sqside\" value=\"\$(sqside)\"/>";
echo "</go>";
echo "</anchor>";
echo "</p>";
echo "</card>"; }

if ($action=="squarearea2") {
echo "<card id=\"card1\" title=\"Area Calc\">";
echo "<p>";
$sqside=$_POST["sqside"];
$area=$sqside * $sqside;
echo "Area of square is:<b>$area</b> units";
echo "</p>";
echo "</card>"; }

///////////////////////Rectangle area//////////////////
if ($action=="rectanglearea") {
echo "<card id=\"card1\" title=\"Area Calc\">";
echo "<p>";
echo "<b>Enter length:</b><br/><input emptyok=\"true\" name=\"rcl\" format=\"*n\" size=\"4\"/><br/>";
echo "<b>Enter width:</b><br/><input emptyok=\"true\" name=\"rcw\" format=\"*n\" size=\"4\"/><br/>";
echo "<anchor title=\"Go\">Go";
echo "<go href=\"calc.php?action=rectanglearea2\" method=\"post\">";
echo "<postfield name=\"rcl\" value=\"$(rcl)\"/>";
echo "<postfield name=\"rcw\" value=\"$(rcw)\"/>";
echo "</go>";
echo "</anchor>";
echo "</p>";
echo "</card>"; }

if ($action=="rectanglearea2") {
$rcl=$_POST["rcl"];
$rcw=$_POST["rcw"];
$rectarea=$rcl * $rcw;
echo "<card id=\"card1\" title=\"Area Calc\">";
echo "<p>";
echo "Area of rectangle is:<b>$rectarea</b> units";
echo "</p>";
echo "</card>"; }


/////////////////////Hypot calc///////////////////////////
if ($action=="hypotcalc") {
echo "<card id=\"card1\" title=\"Hypotenuse Calc\">";
echo "<p>";
echo "<b>X side:</b><br/>";
echo "<input emptyok=\"true\" name=\"a\" size=\"4\"/><br/>";
echo "<b>Y side:</b><br/><input emptyok=\"true\" name=\"b\" format=\"*n\" size=\"4\"/><br/>";
echo "<anchor title=\"Get hypotenuse\">Get hypotenuse";
echo "<go href=\"calc.php?action=hypotcalc2\" method=\"post\">";
echo "<postfield name=\"a\" value=\"$(a)\"/>";
echo "<postfield name=\"b\" value=\"$(b)\"/>";
echo "</go>";
echo "</anchor>";
echo "</p>";
echo "</card>"; }

if ($action=="hypotcalc2") {
$a=$_POST[a];
$b=$_POST[b];
$c=hypot($a,$b);
echo "<card id=\"card1\" title=\"Hypotenuse Calc\">";
echo "<p>";
echo "The hypotenuse of ($a,$b) is $c";
echo "</p>";
echo "</card>"; }
?>
</wml>
Return current item: Wap Calculator