Php To Display Area Of Triangle





Create Form Page

(triangle.html)
<!DOCTYPE html>
<html>
<body>
<form action="tri.php" method="POST">
Enter base:<input type="number" name="n1"><br>
Enter height:<input type="number" name="n2"><br>
<input type="submit" value="submit">
</form>
</body>
</html>

Output




Embed Php File Into Form Page

(tri.php)

<?php
$t=0.5;
$h=$_POST["n1"];
$b=$_POST["n2"];
$tri=$t*$b*$h;
echo "<h1>Area of triangle is:$tri</h1>";
?>




Comments