mirror of
https://github.com/arthur-pbty/nsi.git
synced 2026-06-03 15:07:31 +02:00
update sphere project
This commit is contained in:
@@ -1,27 +1,41 @@
|
||||
<!-- lasphere.php -->
|
||||
|
||||
<html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title> La sphere </title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>The sphere</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body bgcolor="yellow" text="blue">
|
||||
<h1> <font color="black"> Calcul de l'aire de la surface ou du volume d'une sphere </font> </h1>
|
||||
<BR>
|
||||
<img src="sphere.jpg"WIDTH=120 HEIGHT=86 TITLE="code Html" />
|
||||
<!-- edition du formulaire -->
|
||||
<!-- Lors de sa validation par le clic sur le bouton "Envoyer" de type "submit",
|
||||
les données sont envoyées au serveur par la methode POST pour etre exploitees
|
||||
au sein de la page lasphere2.php -->
|
||||
<body>
|
||||
<h1>Calculating the area, surface or volume of a sphere</h1>
|
||||
<img src="sphere.jpg">
|
||||
|
||||
<form method="post" action="lasphere2.php">
|
||||
<p>
|
||||
<input type="radio" name="sphere" value="aire" /> Aire
|
||||
<input type="radio" name="sphere" value="volume" checked="checked" /> Volume
|
||||
<BR>
|
||||
Rayon en m: <input type="text" name="rayon" />
|
||||
<input type="submit" value="Envoyer" />
|
||||
<form method="post">
|
||||
<label for="sphere">Area :</label>
|
||||
<input type="radio" name="sphere" value="aire">
|
||||
|
||||
</p>
|
||||
<label for="sphere">Volume :</label>
|
||||
<input type="radio" name="sphere" value="aire" checked="checked">
|
||||
|
||||
<label for="rayon">Radius in m :</label>
|
||||
<input type="number" name="rayon" required>
|
||||
|
||||
<button type="submit" name="submit">Validate</button>
|
||||
</form>
|
||||
<div>
|
||||
<?php
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['submit'])) {
|
||||
if (strcmp($_POST['sphere'], "aire") == 0) {
|
||||
$resultat = 4 * 3.14 * $_POST['rayon'] * $_POST['rayon'];
|
||||
print ("Aire = $resultat m²");
|
||||
}
|
||||
|
||||
if (strcmp($_POST['sphere'], "volume") == 0) {
|
||||
$resultat = 4/3 * 3.14 * $_POST['rayon'] * $_POST['rayon'] * $_POST['rayon'];
|
||||
print ("Volume = $resultat m3");
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,28 +0,0 @@
|
||||
<!-- lasphere2.php -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title> La sphere </title>
|
||||
</head>
|
||||
<body bgcolor="yellow" text="blue">
|
||||
<h1> <font color="black"> Aire ou volume d'une sphere, le resultat:</font> </h1>
|
||||
<h2>
|
||||
<!-- Code PHP -->
|
||||
<?php
|
||||
/* Comparaison de la chaine de caracteres (string en anglais) reçue de la partie
|
||||
"sphere" du formulaire */
|
||||
// Si la chaine contient la valeur "aire", alors on calcule l'aire de la sphere.
|
||||
if (strcmp($_POST['sphere'], "aire") == 0)
|
||||
{$resultat = 4 * 3.14 * $_POST['rayon'] * $_POST['rayon'];
|
||||
print ("Aire = $resultat m²");
|
||||
}
|
||||
// Si la chaine contient la valeur "volume", alors on calcule le volume de la sphere.
|
||||
if (strcmp($_POST['sphere'], "volume") == 0)
|
||||
{$resultat = 4/3 * 3.14 * $_POST['rayon'] * $_POST['rayon'] * $_POST['rayon'];
|
||||
print ("Volume = $resultat m3");
|
||||
}
|
||||
?>
|
||||
<!-- Fin du code PHP -->
|
||||
</h2>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
form {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
input[type="radio"],
|
||||
input[type="number"],
|
||||
button {
|
||||
margin: 5px;
|
||||
padding: 5px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
div {
|
||||
margin-top: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 300px;
|
||||
height: auto;
|
||||
display: block;
|
||||
margin: 20px auto;
|
||||
border-radius: 10px;
|
||||
}
|
||||
Reference in New Issue
Block a user