MarioDB/oblicz.php

101 lines
2.9 KiB
PHP

<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="brala.css">
</head>
<body>
<?php
if(isSet($_POST['walec'])) {
echo "<form method='post'>
<fieldset>
<legend>dane do walca</legend>
wysokość H = <input type='text' name='h'><br>
promień r = <input type='text' name='r'><br>
<input type='submit' value='oblicz' name='walec'>
</fieldset>
</form>";
}
if(isSet($_POST['w'])) {
$h = $_POST['h'];
$r = $_POST['r'];
$poleW = 2*M_PI*$r*$r+2*M_PI*$r*$h;
$obW = M_PI*$r*$r*$h;
setcookie("poleW",$poleW,time()+60,"/");
setcookie("obW",$obW,time()+60,"/");
setcookie("hw",$h,time()+60,"/");
setcookie("rw",$r,time()+60,"/");
header("Location: brala.php");
}
if(isSet($_POST['stozek'])) {
echo "<form method='post'>
<fieldset>
<legend>dane do stożka</legend>
wysokość H = <input type='text' name='h'><br>
promień r = <input type='text' name='r'><br>
bok l = <input type='text' name='l'><br>
<input type='submit' value='oblicz' name='s'>
</fieldset>
</form>";
}
if(isSet($_POST['s'])) {
$h = $_POST['h'];
$r = $_POST['r'];
$l = $_POST['l'];
$poleS = M_PI*$r*$r+M_PI*$r*$l;
$obS = 1/3*M_PI*$r*$r*$h;
setcookie("poleS",$poleS,time()+60,"/");
setcookie("obS",$obS,time()+60,"/");
setcookie("hs",$h,time()+60,"/");
setcookie("rs",$r,time()+60,"/");
setcookie("ls",$r,time()+60,"/");
header("Location: brala.php");
}
if(isSet($_POST['graniastoslup'])) {
echo "<form method='post'>
<fieldset>
<legend>dane do graniastosłupa</legend>
wysokość H = <input type='text' name='h'><br>
bok a = <input type='text' name='a'><br>
<input type='submit' value='oblicz' name='g'>
</fieldset>
</form>";
}
if(isSet($_POST['g'])) {
$h = $_POST['h'];
$a = $_POST['a'];
$poleG = 2*$a*$a+4*$a*$h;
$obG = $a*$a*$h;
setcookie("poleG",$poleG,time()+60,"/");
setcookie("obG",$obG,time()+60,"/");
setcookie("hg",$h,time()+60,"/");
setcookie("ag",$a,time()+60,"/");
header("Location: brala.php");
}
if(isSet($_POST['ostroslup'])) {
echo "<form method='post'>
<fieldset>
<legend>dane do ostrosłupa</legend>
wysokość H = <input type='text' name='h'><br>
bok a = <input type='text' name='a'><br>
<input type='submit' value='oblicz' name='o'>
</fieldset>
</form>";
}
if(isSet($_POST['o'])) {
$h = $_POST['h'];
$a = $_POST['a'];
$poleO = $a*$a+2*$a*$a*$h;
$obO = 1/3*$a*$a*$h;
setcookie("poleO",$poleO,time()+60,"/");
setcookie("obO",$obO,time()+60,"/");
setcookie("ho",$h,time()+60,"/");
setcookie("ao",$a,time()+60,"/");
header("Location: brala.php");
}
?>
</body>
</html>