Formularios

Introducción

Vamos a abordar a continuación la relación entre PHP y los formularios html. Se trata de uno de los aspectos mas importantes que debemos conocer, ya que los formularios son la via natural mediante la cual enviamos datos a nuestra página php para su procesamiento.

Detrás de la mayoría de aplicaciones php no hay otra cosa que formularios html mediante los cuales el script php puede recolectar los datos que necesita. Por ello se presupone que antes de leer esta sección, debes estar familiarizado con ellos.

Cualquier valor introducido en un formulario html automáticamente se almacena en una variable, pudiendo utilizar este valor en nuestros scripts.

Nociones básicas

Los formularios html van encerrados entre etiquetas <FORM> </FORM>. Esta etiqueta admite diversos atributos, entre ellos los mas importantes, ACTION (que indica la dirección del script que va a procesar la información) y METHOD (que indica la forma de envio de los datos, “post” y “get”)

Dentro de nuestro formulario podemos usar diversos elementos html: INPUT o SELECT, cuyos valores son rellenados por el visitante de la página. Pues bien, al enviar el formulario al script indicado por el atributo ACTION, automáticamente se genera una variable cuyo nombre es el especificado con el atributo NAME y cuyo valor es el introducido por el usuario.

Vamos a ver algo sencillo, que podría servir por ejemplo como inicio para crear un libro de visitas:

<form action="ejemplos/form1.php" method="post">
Nombre:&nbsp;&nbsp; <input type="text" name="nombre" size="20" />
<br><br>
escribe tu mensaje: &nbsp;&nbsp;
<textarea name="mensaje" cols="40" rows="7"></textarea>
<br><br>
tu web:&nbsp;&nbsp;<input type="text" name="url" size="20" />
<br><br>
<input type="submit" name="adguest" value="click para enviar"/>
</form>

Como verás, PHP genera automáticamente variables cuyo nombre-valor es el mismo que el nombre-valor de cada elemento del formulario. También genera un super-array con los mismos elementos.

  • #1 written by nowyadres
    about 6 months ago

    nieruchomosci
    Aquarius Business House in the developer’s intention is to be a large class A office complex, offering a number of recent technological developments. Target object is composed of two 7-storey buildings. Office space around the object is 25 000 sq m
    The project is in the center of Wroclaw, at the intersection of Borowska Relaxed and near the historic city center. This location also provides easy access to airports, motorways and main roads away.
    Office space was designed in an open plan layout, which at high availability of natural light is intended to provide users with the flexibility of arrangements. Offices will be equipped with raised floors, suspended ceilings and air conditioning systems based on czterorurowe.
    In the band office Aquarius Business House planned a number of additional features, the users will be able to use such the medical clinic, lunch, bar, restaurants, cafes, a press lounge, fitness club, and commuters on bikes – from the car park and changing rooms equipped with showers.
    Support facility will offer parking for a total of 412 car seats: 265 in the car park building construction, 97 in the underground car park and 50 in the parking lot outside.
    The project is implemented in two stages. The first one is to end in October 2012. Then – in November 2012 – will begin the second stage, whose completion is scheduled for February 2014
    In Wroclaw the market, Echo Investment has been present since 2007, when it ended with the implementation of shopping and entertainment center “Passage of Grunwald”. Currently, its expansion is planned. In Wroclaw, the project is run housing – housing, “The Slavic Hill” located in the center of the street. National Unity.

No trackbacks yet.