Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentes Révision précédente | |||
| web:php:chap2 [2023/11/08 15:24] – supprimée - modification externe (Unknown date) 127.0.0.1 | web:php:chap2 [2023/11/08 15:24] (Version actuelle) – ↷ Page déplacée de php:chap2 à web:php:chap2 jcheron | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | ====== Chapitre 2 : Méthodes de la requête ====== | ||
| + | |||
| + | |||
| + | < | ||
| + | |||
| + | ===== - Méthode GET ===== | ||
| + | ==== - Soumission ==== | ||
| + | |||
| + | Méthode GET => passage des informations dans l'URL : | ||
| + | |||
| + | === Via un accès direct dans la barre du navigateur : === | ||
| + | |||
| + | {{: | ||
| + | |||
| + | === Via un lien hypertexte === | ||
| + | |||
| + | <sxh html; | ||
| + | <a href=" | ||
| + | </ | ||
| + | |||
| + | === Via un formulaire === | ||
| + | |||
| + | <sxh html> | ||
| + | <form method=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== - Limites du GET ==== | ||
| + | * Limite de taille supportée dans l'URL (IE, Apache) | ||
| + | * Visibilité des informations passées | ||
| + | |||
| + | ==== - Récupération en php ==== | ||
| + | |||
| + | |||
| + | < | ||
| + | |||
| + | |||
| + | Tableau associatif **$_GET** :\\ | ||
| + | <sxh php; | ||
| + | echo $_GET[" | ||
| + | </ | ||
| + | |||
| + | Avec Ubiquity : | ||
| + | |||
| + | <sxh php> | ||
| + | echo URequest:: | ||
| + | </ | ||
| + | |||
| + | ===== - Méthode POST ===== | ||
| + | |||
| + | Les informations sont passées dans les en-têtes HTTP de la requête. | ||
| + | ==== - Soumission via un formulaire ==== | ||
| + | |||
| + | <sxh html> | ||
| + | <form method=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== - Récupération en php ==== | ||
| + | |||
| + | Tableau associatif **$_POST** :\\ | ||
| + | <sxh php; | ||
| + | <?php | ||
| + | echo "Vous recherchez : < | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | Avec Ubiquity :\\ | ||
| + | <sxh php> | ||
| + | <?php | ||
| + | echo "Vous recherchez : < | ||
| + | ?> | ||
| + | </ | ||
| + | ==== - Définir l' | ||
| + | |||
| + | <sxh php> | ||
| + | <form method=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ==== - Identifier la méthode ==== | ||
| + | |||
| + | <sxh php> | ||
| + | <?php | ||
| + | if (strtoupper($_SERVER[' | ||
| + | echo(" | ||
| + | else | ||
| + | echo (" | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | Avec Ubiquity : | ||
| + | |||
| + | <sxh php> | ||
| + | <?php | ||
| + | if (URequest:: | ||
| + | echo(" | ||
| + | else | ||
| + | echo (" | ||
| + | ?> | ||
| + | </ | ||
| + | ==== - Empêcher les requêtes Cross-site ==== | ||
| + | |||
| + | <sxh php> | ||
| + | <?php | ||
| + | if (stripos($_SERVER[' | ||
| + | echo " | ||
| + | } | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | Avec Ubiquity : | ||
| + | |||
| + | <sxh php> | ||
| + | <?php | ||
| + | if (URequest:: | ||
| + | echo " | ||
| + | } | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | ===== - GET et POST ===== | ||
| + | |||
| + | <sxh html> | ||
| + | <form method=" | ||
| + | <label for=" | ||
| + | <input type=" | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | |||
| + | <sxh php; | ||
| + | <?php | ||
| + | echo "Vous recherchez : < | ||
| + | echo " | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | Avec Ubiquity : | ||
| + | |||
| + | <sxh php> | ||
| + | <?php | ||
| + | echo "Vous recherchez : < | ||
| + | echo " | ||
| + | ?> | ||
| + | </ | ||