Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
IbraZaou committed Aug 5, 2022
1 parent b8825be commit eab8298
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commande-chocolat/_config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

define('TARIF', 20);
define('REMISE', 5);
// création de la constante 'TARIF'
Binary file added commande-chocolat/img/chocolat-bg.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added commande-chocolat/img/macaron.webp
Binary file not shown.
39 changes: 39 additions & 0 deletions commande-chocolat/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
include('_config.php');
?>

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Commander</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div>
<form action="traitement.php" method="post" >
<!-- post: permet d'envoyer des variables qui ne se passe pas dans l'URL-->
<label for="quantite">Quantité: </label>
<select name="quantite" id="quantite"> <!-- menu déroulant -->
<!-- id = mettre en relation avec le label
name = permet la récupération la quantité chosis par l'utilisateur -->
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<p>Tarif: <?= TARIF; ?> €</p>
<!-- echo + constante definev(^) -->
<p>En commandant maintenant, vous aurez droit à une remise immediate de <?= REMISE; ?>€.</p>
<p>
<input type="submit" value="Commander">
</p>

<img src="img/macaron.webp" alt="">
</form>
</div>
</body>
</html>
76 changes: 76 additions & 0 deletions commande-chocolat/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
body{
margin: 0;
font-family: sans-serif;
font-size: 1.3rem;
background-image: url(./img/chocolat-bg.jpeg);
background-repeat: no-repeat;
background-size: cover;
background-position: center;
background-attachment: fixed;

display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

div {
max-width: 400px;
background-color: rgba(255,255,255,0.8);
box-shadow: 3px 3px 5px #555;
padding: 20px;
text-align: center;
border-radius: 10px;
}

select {
font-size: 1.3rem;
padding: 3px 20px;
border-radius: 50px;
border: 2px solid orangered;
outline: none;
/* liserai autour du selecteur */
background: none;
}

input[type="submit"] {
padding: 10px 40px;
border-radius: 50px;
border: none;
background-color: orangered;
color: white;
font-size: 1.4rem;
cursor: pointer;
box-shadow: 3px 3px 5px #333;
outline: none;
transition: .5s;
}

input[type="submit"]:hover{
background-color: orange;
color: black;
transform: translateY(-7px);
}

img {
width: 100%;
border-radius: 50px;
/* elle va occuper 100% de la boite div */
}

h1{
font-size: 1.5rem;
color: orangered;
}

ul{
text-align: left;
}

.orangered{
color: orangered;
font-weight: 700;

}


32 changes: 32 additions & 0 deletions commande-chocolat/traitement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
include('_config.php');
// Calcul du Total à payer
$total = $_POST['quantite'] * TARIF;
$newTotal = $total - REMISE;
?>



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Traitement</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div>
<h1>Merci pour votre commande</h1>
<ul>
<li>Nombre de boites commandées: <?= $_POST['quantite']; ?> </li>
<!-- tu reprend du form car method POST donc "$_POST" et ca va prendre le "quantite" du select -->
<li>Tarif unitaire: <?= TARIF; ?> €</li>
<li>Total à payer: <?= $total; ?> €</li>
<li>Remise: <?= REMISE; ?>€</li>
<li><strong>nouveau Total:</strong> <span class="orangered"> <?= $newTotal; ?> €</span></li>
</ul>
</div>
</body>
</html>

0 comments on commit eab8298

Please sign in to comment.