$_POST

Array
(
)

$_GET

Array
(
)

Premier formulaire






Un autre



Un avec method=GET





Code

1 <?php
2
/* Utilisation de $_POST zr $_GET
3     $_POST et $_GET s'utilisent exactement pareil, $_GET c'est dans l'url, $_POST c'est "invisible".
4 */
5
echo '<h1>$_POST</h1>';
6 echo 
"<pre>";
7
print_r($_POST);
8 echo 
"</pre>";
9
10
11 echo 
'<h1>$_GET</h1>';
12 echo 
"<pre>";
13
print_r($_GET);
14 echo 
"</pre>";
15
16
?>
17

18 <h1>Premier formulaire</h1>
19 <form method="post" action="exemple9.php">
20     <input type="text" name="text1" value="5" /><br/>
21     <input type="text" name="unautreinput" /><br/>
22     <select name="unselect">
23         <option value="1">Jaune</option>
24         <option value="2">Vert</option>
25     </select><br/>
26     <input type="hidden" name="jesuiscaché" value="ici" /><br/>
27     <textarea name="untext" rows="5" cols="20">
28     du texte
29     </textarea>
30     <input type="submit" value="Envoyer" /><br/>
31 </form>
32
33
34 <h2>Un autre</h2>
35 <form method="post" action="exemple9.php?testouille=lala">
36     <input type="text" name="unautreinput" value="<? if(isset($_POST['unautreinput'])) echo $_POST['unautreinput']; ?>"/><br/>
37     <textarea name="untext" rows="5" cols="20">
38
39     </textarea>
40     <input type="submit" value="Envoyer" /><br/>
41 </form>
42
43 <h2>Un avec method=GET</h2>
44 <form method="get" action="exemple9.php">
45     <input type="text" name="text1" value="5" /><br/>
46     <input type="text" name="unautreinput" /><br/>
47     <input type="submit" value="Envoyer" /><br/>
48 </form>
49
50 <?
51
/* On s'en fout là, c'est juste pour afficher la source */
52
include("hl.php");
53
hl('exemple9.php');
54
?>