Ver Mensaje Individual
  #9 (permalink)  
Antiguo 20/04/2008, 10:16
reimonfranco
 
Fecha de Ingreso: febrero-2006
Mensajes: 858
Antigüedad: 18 años, 2 meses
Puntos: 4
Re: Novato Necesita Ayuda

Este es un libro de visitas , los datos se guardan en un .txt

Código PHP:
<?
setcookie
("visit",1,time() + 8640 365);
?>
<html>
<head>
<style>
body {color:red;text-align:center;font-family:Gill Sans MT;font-size:10pt};

</style>
</head>
<title>Php5</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#000000">
<div align="center">
  <p><font color="#FFFFFF" size="6" face="Gill Sans MT"><?php if (isset($_COOKIE['visit']) && $_COOKIE['visit'] ==  1) { ?> Bievenido de nuevo a mi libro de visitas <?php } else { ?> Bievenidos por primera vez a mi libro de visitas<?php ?> </font></p>
  <form method='post'>
  <p align="center"><font color="#FFFF00" size="3" face="Gill Sans MT">Tu nombre: 
    <input name="name" type="text" id="name">
    </font></p>
  <p align="center"><font color="#FFFF00" size="3" face="Gill Sans MT">Tu email: 
    <input name="email" type="text" id="email">
    </font></p>
  <p align="center"><font color="#FFFF00" size="3" face="Gill Sans MT">Comentario</font></p>
  <p align="center"><font color="#FFFF00" size="3" face="Gill Sans MT"> 
    <textarea name="comment" cols="50" rows="5"></textarea>
    </font></p>
  <p align="center"><font color="#FFFF00" size="3" face="Gill Sans MT">
     <input type='submit' name='mibtn' value='Insertar comentario'>
    </font></p>
    </form>
</div></p>
</div>
<?
$file 
"miguestbook.txt";
if (isset(
$_POST['comment']) && $_POST['name'] != "" && $_POST['email'] != "") {
$nombre $_POST['name'];
$email $_POST['email'];
$comment $_POST['comment'];
$fp fopen($file,"r+");
$lectura fread($fp,filesize($file));
$email "<a href='maito:$nombre'>$email</a>";
$fecha date("j:n:Y");
$todo "<p></b>"htmlentities($nombre) ."</b> ("htmlentities($email) .")  <i>"htmlentities($fecha) ."</i>: <br>"htmlentities($comment) ."</p>\n";  
$comment htmlspecialchars($comment);
$comment stripslashes($comment); 
$comment nl2br($coment);
rewind($fp);
fputs($fp,"$todo \n $lectura");
fclose($fp);
}
else {
if (isset(
$_POST['mibtn']))
{
echo 
"Debes completar todos los campos";
}
}
?>
<div align='center' style="margin:90px;padding:10px;border:1px dotted red">
<?
readfile
($file);

?>
</div>
</body>
</html>
y en la carpeta donde pongas esto tienes que crear un archivo en blanco llamado:
miguestbook.txt

saludos
__________________
*La amistad se multiplica cuando se divide*