Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <form class="" action="index3.php" method="post">
  11. <label for="mot">Entrez le mot a traduire :</label>
  12. <input type="text" name="mot">
  13. <input type="submit" value="Valider">
  14. <select class="" name="direction">
  15. <option value="toEnglish">Francais -> Anglais</option>
  16. <option value="toFrench">Anglais -> Francais</option>
  17. </select>
  18.  
  19. <?php
  20. $traductions = array(
  21. "chat" => "cat",
  22. "chien" => "dog",
  23. "maison" => "home",
  24. "voiture" => "car"
  25. );
  26.  
  27. $copieTrad = $traductions;
  28.  
  29. if (isset($_POST["direction"])) {
  30. $selectOption = $_POST["direction"];
  31. if ($selectOption == 'toFrench') {
  32. $copieTrad = array_flip($copieTrad);
  33. } else {
  34. $copieTrad = $traductions;
  35. }
  36. }
  37.  
  38. if (isset($_POST["mot"])) {
  39. $traduire = strtolower($_POST["mot"]);
  40. if (array_key_exists($traduire, $copieTrad)) {
  41. echo "Le mot"." ".$traduire." "."se traduit par"." ".$copieTrad[$traduire];
  42. } else {
  43. echo "Je ne connais pas ce mot, désolé...";
  44. }
  45. } else {
  46. echo " ";
  47. }
  48.  
  49. ?>
  50. </form>
  51. </body>
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement