image


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




Data delivery and reception

The PHP language provides us with a simple way to handle forms, enabling us to process information inserted by the user.

When designing the form, we must indicate the PHP page that will process the form, as well as the method used to insert the information into the page.

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

Execute View code

By pressing the "Send" button, the content in the text box is sent to the page indicated in the attribute ACTION of the FORM tag.

In versions previous to 4.2.0, PHP created a variable for each element of FORM, this created variable had the same name than the text box in the previous page and the value already inserted. But due to safety reasons, since then in order to have access to the form variables, we shall use the parameters array $_POST[] or $_GET[] depending on the method used to send the parameters.

In this example, we have created an entrance in the array $_GET[] with the index 'name' and with the value inserted by the web browser.

<!-- PHP Tutorial WebEstilo.com -->
<html>
<head>
   <title>PHP Example</title>
</head>
<body>
<H1>Processing forms</H1>
Name: <?php echo $_GET['name'] ?>
<br>
</body>
</html>

View code





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