image


Valora:  2.33/5
Inicio » PHP » PHP Tutorial » Processing forms




Method GET y POST

In the previous page we have indicated that data in a form is sent through the method indicated in the attribute METHOD of the tag FORM, the two possible methods are GET and POST.

The difference between these two methods is in the way of sending data to the page, while the GET method sends data using URL, the POST method sends them through the standard entrance STDIO

<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
   <title>PHP Example</title>
</head>
<body>
<H1>Processing forms</H1>
<FORM ACTION="procesa2.phtml" METHOD="GET">
Insert your first name:<INPUT TYPE="text" NAME="name"><BR>
Insert your last name:<INPUT TYPE="text" NAME="last"><BR>
<INPUT TYPE="submit" VALUE="Enviar">
</FORM>
</body>
</html>

Execute View code


<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
   <title>PHP Example</title>
</head>
<body>
<H1>Processing forms</H1>
<FORM ACTION="procesa2.phtml" METHOD="POST">
Insert your first name:<INPUT TYPE="text" NAME="name"><BR>
Insert your last name:<INPUT TYPE="text" NAME="last"><BR>
<INPUT TYPE="submit" VALUE="Enviar">
</FORM>
</body>
</html>

Execute View code


procesa2.phtml
<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
   <title>PHP Example</title>
</head>
<body>
<H1>Processing forms</H1>
Your name by GET: <?php echo $_GET['name']," ",$_GET['last'] ?><br>
Your name by POST: <?php echo $_POST['name']," ",$_POST['last'] ?>
<br>
</body>
</html>

View code

The final result is the same, but with the GET method we can see the past parameters since they are codified in the URL.






WebEstilo.com - Introduzca su e-mail y conozca las novedades. No hacemos Spam.
Google
  Web WebEstilo.com   
 
Valid HTML 4.01!
Última modificación:25 de Diciembre de 2004. Spain - España.
© 1998-2004 por Joaquin Gracia. Todos los derechos reservados.