Upload files to "php"

This commit is contained in:
Sebastian Ranoszek 2025-01-22 19:24:52 +00:00
parent f041034f5e
commit 029f672277
3 changed files with 209 additions and 0 deletions

39
php/brala.css Normal file
View File

@ -0,0 +1,39 @@
#figura {
width: fit-content;
margin-left:auto;
margin-right: auto;
margin-top: 3%;
}
#figura input {
width: 200px;
font-size: 140%;
height: 50px;
font-weight: bold;
border-radius: 20px;
}
.wynik {
float: left;
font-size: 150%;
color:navy;
margin: 40px 50px;
font-weight: bold;
}
fieldset {
margin-top:8%;
margin-left:10%;
width: fit-content;
padding: 20px 60px;
line-height: 2em;
font-size:200%;
background: linear-gradient(to left,red,gold);
}
fieldset input {
width: 4em;
}
legend {
font-weight: bold;
}
fieldset input[type="submit"] {
width: 6em;
font-size: 0.6em;
}

69
php/brala.php Normal file
View File

@ -0,0 +1,69 @@
<!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>
<div id="figura">
<table>
<tr>
<th><img src="./walec.jpg" alt="walec" title="walec"></th>
<th><img src="./stozek.jpg" alt="stożek" title="stożek"></th>
<th><img src="./graniastoslup.jpg" alt="granistosłup" title="granistosłup"></th>
<th><img src="./ostroslup.jpg" alt="ostrosłup" title="ostrosłup"></th>
</tr>
<form action="oblicz.php" method="post">
<tr>
<th><input type="submit" value="walec" name="walec"></th>
<th><input type="submit" value="stożek" name="stozek"></th>
<th><input type="submit" value="graniastosłup" name="graniastoslup"></th>
<th><input type="submit" value="ostrosłup" name="ostroslup"></th>
</tr>
</form>
</table>
</div>
<div id="wynik">
<?php
echo "<div class='wynik'>";
if(isSet($_COOKIE['poleW'])) {
echo "H = ",$_COOKIE['hw'],"<br>";
echo "r = ",$_COOKIE['rw'],"<br>";
echo "pole walca = ",number_format($_COOKIE['poleW'],3),"<br>";
echo "objętość walca = ",number_format($_COOKIE['obW'],3),"<br>";
//setcookie("poleW","",time()-50,"/");
}
echo "</div>";
echo "<div class='wynik'>";
if(isSet($_COOKIE['poleS'])) {
echo "H = ",$_COOKIE['hs'],"<br>";
echo "r = ",$_COOKIE['rs'],"<br>";
echo "l = ",$_COOKIE['ls'],"<br>";
echo "pole stożka = ",number_format($_COOKIE['poleS'],3),"<br>";
echo "objętość stożka = ",number_format($_COOKIE['obS'],3),"<br>";
//setcookie("poleS","",time()-60,"/");
}
echo "</div>";
echo "<div class='wynik'>";
if(isSet($_COOKIE['poleG'])) {
echo "H = ",$_COOKIE['hg'],"<br>";
echo "a = ",$_COOKIE['ag'],"<br>";
echo "pole graniastosłupa = ",number_format($_COOKIE['poleG'],3),"<br>";
echo "objętość graniastosłupa = ",number_format($_COOKIE['obG'],3),"<br>";
}
echo "</div>";
echo "<div class='wynik'>";
if(isSet($_COOKIE['poleO'])) {
echo "H = ",$_COOKIE['ho'],"<br>";
echo "a = ",$_COOKIE['ao'],"<br>";
echo "pole ostrosłupa = ",number_format($_COOKIE['poleO'],3),"<br>";
echo "objętość ostrosłupa = ",number_format($_COOKIE['obO'],3),"<br>";
}
echo "</div>";
?>
</div>
</body>
</html>

101
php/oblicz.php Normal file
View File

@ -0,0 +1,101 @@
<!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>