Méthode GET ⇒ passage des informations dans l'URL :
< a href = "https://www.google.fr/#q=m%C3%A9thode+get" >rechercher des infos sur la méthode GET avec Google</ a > |
1 2 3 4 |
< form method = "GET" action = "resultats.php" > < label for = "search" >Rechercher sur mon site : </ label >< input type = "text" name = "search" id = "search" > < input type = "submit" value = "Rechercher" > </ form > |
mapage.php?version=1.0.0.1
Tableau associatif $_GET :
1 |
echo $_GET [ "version" ]; |
Avec Ubiquity :
1 |
echo URequest::get( "version" ); |
Les informations sont passées dans les en-têtes HTTP de la requête.
1 2 3 4 |
< form method = "POST" action = "resultats.php" > < label for = "search" >Rechercher sur mon site : </ label >< input type = "text" name = "search" id = "search" > < input type = "submit" value = "Rechercher" > </ form > |
Tableau associatif $_POST :
1 2 3 |
<?php echo "Vous recherchez : <b>" . $_POST [ "search" ]. "</b>" ; ?> |
Avec Ubiquity :
1 2 3 |
<?php echo "Vous recherchez : <b>" .URequest::post( "search" ). "</b>" ; ?> |
1 2 |
<form method= "post" action= "<?php echo $_SERVER['PHP_SELF']?>" > </form> |
1 2 3 4 5 6 |
<?php if ( strtoupper ( $_SERVER [ 'REQUEST_METHOD' ]) == 'POST' ){ echo ( "méthode POST utilisée" ); else echo ( "méthode GET" ); ?> |
Avec Ubiquity :
1 2 3 4 5 6 |
<?php if (URequest::isPost()){ echo ( "méthode POST utilisée" ); else echo ( "méthode GET" ); ?> |
1 2 3 4 5 |
<?php if ( stripos ( $_SERVER [ 'HTTP_REFERER' ], $_SERVER [ 'SERVER_NAME' ])===FALSE){ echo "Tentative de requête cross-site" ; } ?> |
Avec Ubiquity :
1 2 3 4 5 |
<?php if (URequest::isCrossSite()){ echo "Tentative de requête cross-site" ; } ?> |
1 2 3 4 |
< form method = "POST" action = "resultats.php?number=1" > < label for = "search" >Rechercher sur mon site : </ label >< input type = "text" name = "search" id = "search" > < input type = "submit" value = "Rechercher" > </ form > |
1 2 3 4 |
<?php echo "Vous recherchez : <b>" . $_POST [ "search" ]. "</b><br>" ; echo "Number : <b>" . $_GET [ "number" ]. "</b>" ; ?> |
Avec Ubiquity :
1 2 3 4 |
<?php echo "Vous recherchez : <b>" .URequest::post( "search" ). "</b><br>" ; echo "Number : <b>" .URequest::get( "number" ). "</b>" ; ?> |