Ver Mensaje Individual
  #2 (permalink)  
Antiguo 28/05/2003, 19:17
Avatar de nuevo
nuevo
 
Fecha de Ingreso: mayo-2003
Ubicación: Spain
Mensajes: 2.009
Antigüedad: 21 años
Puntos: 2
a ver si te sirve

mira este codigo es de Camargo, es un ejemplo muy sencillo del cual puedes aprender bastante sobre como ingresar y leer datos de una DB en texto plano.... con permiso de Camargo lo voy a poner....


1º. Haz un directorio y un archivo llamado "base.txt"
2º. Copia este codigo a un fichero llamado "firmilla.php"


<body link=#000000 alink=#000000 vlink=#000000>
<?php

//VARIABLES A EDITAR//

$primer = "#eeeeee"; // COLOR TABLA 1
$segunda = "#e8edf2"; // COLOR TABLA 2
$fontface = "Arial"; // FONTFACE
$fontcolor = "#000000"; // COLOR DE LA FONT
$fontsize = "1"; // TAMAÑO DE LA FONT [SIZE]

//FIN DE VARIABLES//

if($accion=="agregar"){
if (empty($nick)){
echo "<b>No has puesto tu nick..</b><br>";
}
if(empty($mensaje)){
echo "<b>No has puesto ningun mensaje..</b><br>";
} else {

$mensaje = ereg_replace("\r\n","<br>", $mensaje);
$incluir="$nick|$mensaje\n";

$a1 = fopen("base.txt", "a+");
flock($a1,2);
$fw = fwrite($a1, $incluir);
fclose($a1);

}
}

if($accion!="firmar"){
echo "<table width=120 border=0 cellspacing=0 align=center cellpadding=0>";
echo "<tr>";
echo "<div align=center><font size=$fontsize color=$fontcolor><b><font face=$fontface><a href=firmilla.php?accion=firmar><img src=up.gif width=120 border=0></font></a>";
echo "</div></table>";

$ficherobase = file("base.txt");
$largo = sizeof($ficherobase);
$largo = $largo - 1;

for($i=$largo ; $i>-1 ; $i--) {

$mensaje = explode("|", $ficherobase[$i]);

echo "<table width=120 border=0 cellspacing=1 align=center cellpadding=2 bgcolor=#CCCCCC>";
echo "<tr>";
echo "<td bgcolor=$primer width=120><font size=$fontsize color=$fontcolor face=$fontface>-$mensaje[0]-";
echo "<font size=$fontsize color=$fontcolor face=$fontface>$mensaje[1]</td>";
echo "</tr></table><table width=100 height=1><tr><td height=1></td></tr></table>";
}
echo "<font size=1 face=Verdana><a href=http://www.elpar.net target=_blank>
<center><b>Script by elPar.net</a></center></font>";
}

if($accion=="firmar"){
echo "<form method=POST action=firmilla.php?accion=agregar>";
echo "<input type=text maxlength=7 name=nick value=\"Tu Nick\" size=13><br>";
echo "<textarea name=mensaje cols=11 rows=2>Firmilla</textarea><br>";
echo "<input type=submit name=Submit value=Enviar><input type=reset name=Submit2 value=Borrar>";
echo "</form>";
echo "<a href=firmilla.php><font size=$fontsize color=$fontcolor face=$fontface>Atras</a>";

}

?>
</html>
</body>

------------------------------------------------------------------------------

>>> PON ESTE CODIGO EN TU WEB>>>> IFRAME

<script>var dir='firmilla.php';
document.write('<iframe src="'+dir+'" width="140" height="150" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="yes" target="_top"></iframe>');
document.write('<ilayer src="'+dir+'" width="140" height="150"></ilayer>');
</script>

------------------------------------------------------------------------------

Saludos y espero que te sirva de algo... a mi me ayudo mucho ;), y espero que no le moleste a Camargo....bye