Este documento describe el código PHP utilizado para crear un formulario web que permite a los usuarios ingresar su nombre y mensaje. Cuando se envía el formulario, el código en lee.php almacena la entrada en un archivo de texto llamado archivo.txt. El código en index.php muestra el contenido existente de archivo.txt y también incluye el formulario para nuevas entradas.
Tabla comparativa de paradigma de la poo y programacion estructurada
Registros wouy
1. UNIVERSIDAD TECNONOLÓGICA DEL ESTADO DE ZACATECAS
UNIDAD ACADÉMICA DE PINOS
TECNOLOGÍAS DE LA INFORMACIÓN Y COMUNICACIÓN
MONICA DE LOS ANGELES RAMIREZ MORENO
TECNOLOGIAS DE LA INFORMACION Y COMUNICACIÓN(Tics)
ELOY CONTRERAS DE LIRA
4°”A”
09/OCTUBRE/2013
2. UNIVERSIDAD TECNONOLÓGICA DEL ESTADO DE ZACATECAS
UNIDAD ACADÉMICA DE PINOS
TECNOLOGÍAS DE LA INFORMACIÓN Y COMUNICACIÓN
EN EL INDEX.PHP es el siguiente codigo:
<body>
<form id="form1" name="form1" method="post" action="lee.php">
<table width="244" border="1">
<tr align="center">
<td width="234"> nombre
<label for="nom"></label>
<label for="nombre"></label>
<input type="text" name="nombre" id="nombre"></td>
</tr>
<tr align="center">
<td>mensaje
<label for="ms"></label>
<label for="mensaje"></label>
<input type="text" name="mensaje" id="mensaje"></td>
</tr>
<tr align="center">
<td><input type="submit" name="enviar" id="enviar" value="ENVIAR" /></td>
</tr>
</table>
</form>
<?php
$fp=fopen("archivo.txt","r");
3. UNIVERSIDAD TECNONOLÓGICA DEL ESTADO DE ZACATECAS
UNIDAD ACADÉMICA DE PINOS
TECNOLOGÍAS DE LA INFORMACIÓN Y COMUNICACIÓN
while(!feof($fp)){
echo fgets($fp). "<br/>";
}
fclose($fp);22221
?>
</body>
</html>
EN LEE.PHP es el siguiente codigo:
<?php
$nombre = $_REQUEST['nombre'];
$mensaje = $_REQUEST['mensaje'];
$linea = $nombre."t".$mensaje."n";
$fp=fopen("archivo.txt","a");
fputs($fp,$linea);
fclose($fp);
?>