Formulaire PHP [EXO(9)] - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Formulaire PHP [EXO(9)].php

  1. BIENVENUE au FORMULAIRE PHP (exo9) <br>
  2. Veuillez entrer les prix et le nombre :
  3.  
  4. <form method ="POST" action="Calcul.php">
  5.     Prix de la table : <input type="number" name="prixtable" required><br>
  6.     Prix de l´armoire :<input type="number" name= "prixarmoire"requires><br>
  7.     Nombre: <input type="number " name="nombre" required><br>
  8.     
  9.     <input type ="submit" value="Calculer le total" >
  10. </form> 
  11.  
  12.  
  13. <?php
  14. // en entrant les données dans le formulaire on les envoies dans le fichier calcul.php afin d´etre traitées.
  15. if (isset($_SERVER["REQUEST_METHOD"]) && $_SERVER["REQUEST_METHOD"] == "POST") {
  16.     $prix_table = $_POST["prixtable"];
  17.     $prix_armoire = $_POST["prixarmoire"];
  18.     $nombre = $_POST["nombre"];
  19.      echo "Prix de la table: " . $prix_table . "<br>";
  20.      echo "Prix de l'armoire: " . $prix_armoire . "<br>";
  21.      echo "Nombre: " . $nombre . "<br>";
  22.     
  23.      // Calculer le total
  24.      $Prix_total = $prix_table * $prix_armoire * $nombre;;
  25.  
  26.     // Afficher le total
  27.     echo "Le total est : " . $Prix_total . "€";
  28. }
  29. ?>
  30.  
  31.  
  32. BIENVENUE AU FORMULAIRE de l´exo10:<br>
  33. Veuillez entrer vos données:
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
File Description
  • Formulaire PHP [EXO(9)]
  • PHP Code
  • 06 Feb-2024
  • 1.1 Kb
You can Share it: