Leggere i parametri - POST e GET - Esempio - Sorgente

<html><head>
<title>Lezioncina sul PHP - 17</title>
<meta name="author" content="Ing. Stefano Salvi">
</head>
<body bgcolor=#ffffcc text=#000080 vlink=#0040cc link=#0080ff>
<table width=100% height=100%><tr>
<td width=90% valign=middle>
<h1 align=center><font size=+5>Leggere i parametri - POST e GET - Esempio</font></h1>
</td><td width=90 valign=middle><img src=php.jpg align=right border=0 usemap=#mymap></td></tr>
<map name=mymap>
<area shape=rect coords=0,0,30,90 href=16.html>
<area shape=rect coords=30,0,60,90 href=index.html>
<area shape=rect coords=60,0,90,90 href=18.html>
</map>
<tr>
<td height=80% valign=middle align=left colspan=2>
<font size=+3><ul>
<li><form action=17.php method=get>
Campo: <input type=text name=campo>
<input type=checkbox name=check> Check<br>
<input type=radio value=uno name=radio checked> Uno
<input type=radio value=due name=radio> Due
<select name=select><option value=primo">Primo</option>
<option value="secondo">Secondo</option>
<option value="terzo">Terzo</option></select>
<input type=hidden name=method value=GET>
<input type=submit value="Invia - GET"></form>
<li><form action=17.php method=post>
Campo: <input type=text name=campo>
<input type=checkbox name=check> Check<br>
<input type=radio value=uno name=radio checked> Uno
<input type=radio value=due name=radio> Due
<select name=select><option value="primo">Primo</option>
<option value="secondo">Secondo</option>
<option value="terzo">Terzo</option></select>
<input type=hidden name=method value=POST>
<input type=submit value="Invia - POST"></form>
<?php
  $method = $_REQUEST ["method"];
  if ($method) {
    echo "<li>Campo <B>$_REQUEST[campo]</B>; Check <B>$_REQUEST[check]</B>; Radio: <B>$_REQUEST[radio]</B>;\n";
    echo "Select: <B>$_REQUEST[select]</B>; Metodo <B>$method</B>;";
  } else {
    echo "<li>Nessun dato in ingresso\n";
  }
?>
<li><A HREF="17.s.php">Sorgente</A>
</ul></font></td></tr></table>
<p align=right><i>&copy; Ing. Stefano Salvi - </i>released under <a
 href="http://www.gnu.org/licenses/fdl.txt"
 title="Testo inglese della FDL presso www.gnu.org">FDL licence</a></p>
</body>
</html>

© Ing. Stefano Salvi - released under FDL licence