para enpezar necesitamos estor archivos:
enviar.php : aka esta el formulario del comentario
redireccionar.php : aka agredecemos po e post ylo invtamos aver el post
index.php : aka estan los comentarios que nos envian
contador.txt : aka como se dice nos da la cantiddad de comentaros.
datos.txt : aka se almacenan los comentarios
aka estan los codigos!
enviar.php
Código PHP:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Enviar Comentarios!</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
.style2 {color: #FFFFFF}
#apDiv1 {
position:absolute;
left:168px;
top:15px;
width:246px;
height:27px;
z-index:1;
}
#apDiv2 {
position:absolute;
left:181px;
top:65px;
width:182px;
height:22px;
z-index:2;
}
body,td,th {
color: #000000;
}
-->
</style></head>
<body>
<form action="<?=$PHP_SELF?>redireccionar.php" method="post" class="style2">
<table width="250" border="0">
<tr>
<th scope="col">Ingresa tu Nick/Nombre</th>
</tr>
<tr>
<th scope="col"><input name="nombre" type="text" /></th>
</tr>
<tr>
<th scope="row">Ingresa Tu Comentario</th>
</tr>
<tr>
<th scope="row"><textarea name="apellidos"></textarea> </th>
</tr>
</table>
<br />
<input type="submit" value="Enviar" />
</form>
</span>
</body>
</html>
redireccionar.php
Código PHP:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Redireccion...</title>
<style type="text/css">
<!--
.style2 {
font-family: "Comic Sans MS";
font-weight: bold;
font-size: 16px;
}
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
color: #000000;
text-decoration: none;
}
a:hover {
color: #FF0000;
text-decoration: none;
}
a:active {
color: #000000;
text-decoration: none;
}
a {
font-size: 14px;
font-weight: bold;
}
.style3 {font-family: "Comic Sans MS"}
.style4 {font-size: 16px}
.style6 {font-size: 16}
.style8 {font-size: 14px}
.style9 {font-family: "Comic Sans MS"; font-size: 14px; }
-->
</style>
<body>
<?php #aka se gurdan los archivos resividos del formulario
if(isset($_POST['nombre'],$_POST['apellidos'])){
#se abre el fichero en modo lectura y escritura.
$archivo = fopen("datos.txt","a+");
#se crea uan variable con los datos a introducir. \r\n genera un salto de linea
$cadena = "Nombre: ".$_POST['nombre'].".\r\nComentarios: ".$_POST['apellidos'].".\r\n\r\n";
fputs($archivo,$cadena);
#se cierra el fichero
fclose($archivo);
} #aka porcada ves que se le de enviar el vacontando el este archivo
$archi = 'contador.txt';
$auxi = fopen($archi, 'rb');
$Visitas = fgets($auxi, 10);
$Visitas++;
fclose($auxi);
$auxi = fopen($archi, 'wb');
fwrite($auxi, $Visitas);
fclose($auxi);
?>
<p class="style2">Gracias por tu Comentarios</p>
<p class="style1"> <span class="style3"><span class="style4"><span class="style6"><span class="style8"><a href="index.php">Has Click aki para ver tu Comentario</a></span></span></span></span></p>
<p class="style1"><span class="style9"><a href="javascript:window.close()">Has Click aki para salir de la web</a></span></p>
</body>
</html>
index.php
Código PHP:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Comentarios</title>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
}
.style1 {
color: #000000;
font-family: "Comic Sans MS";
}
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #FF0000;
}
a:active {
text-decoration: none;
color: #000000;
}
-->
</style>
</head>
<body>
<p class="style1"><a href="enviar.php">Has Click aki para enviar tu comentario!</a></p>
<p align="left" class="style1">Actualmente hay <?php #mostramos la cantidad de comentarios
$path = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
$archivo = file($path."contador.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++){
echo $archivo[$i]."<br>";
}?>Comentarios</p>
</body>
</html>
<table width="250" border="0" align="justify">
<tr>
<th scope="col"><?php #aka los comentarios
$path = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];
$archivo = file($path."datos.txt");
$lineas = count($archivo);
for($i=0; $i < $lineas; $i++){
echo $archivo[$i]."<br>";
}
?></th>
</tr>
</table>
eso es todo solo deben de crear los datos.txt vacios sin nada!
y el contador.txt os deben crear con un "0" y luego el 0 se sustituira por e 1 y asi susesivamente
espero aver sido explicito si tienes dudas me avisan!
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)
![Afirmando](http://static.forosdelweb.com/fdwtheme/images/smilies/afirmar.gif)