Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/12/2004, 22:48
jcespedes
 
Fecha de Ingreso: noviembre-2004
Mensajes: 11
Antigüedad: 19 años, 4 meses
Puntos: 0
Script guestbook en PHP

Esto es lo primero que hace este script.

1- llama un template llamado tpl_arriba.html
2- muestra [firmar libro] accion=firmar
3- llama el template tpl_mensajes.html
4- muestra [firmar libro] accion=firmar otravez

cuando hago click sobre [firmar libro] el script sustituye el template tpl_mensajes.html por tpl_formulario.html, pero el [firmar libro] de arriba o sea el de la opcion numero 2 especificada arriba se queda visible el de la opcion 4 desaparece que es lo que quiero que hagan ambos porque si ya estoy en el formulario no quiero ver [firmar libro] mas, agredezco cualquier ayuda por favor tengo 3 dias con este mismo problema.

aqui está:

<?
require_once("config.php");
require_once("funciones.php");



Template("html/tpl_arriba.html");


echo "<table cellpadding='4' cellspacing='1' width='380' align='center' class='normal'>";
echo "<tr><td width='380'>";
Paginacion();
echo "</td><td width='380' align='right'>";
echo "<b><a href='index.php?accion=firmar'>Firmar libro</a></b>";
echo "</td></tr></table>";


switch($accion) {

// Formulario para publicar un mensaje

case firmar:
Template("html/tpl_formulario.html");
break;

// Publicar un mensaje

case publicar:

$fecha = date("d-m-y H:i a");

// Comprobación de campos

$nombre = trim($nombre);
$email = trim($email);
$mensaje = trim($mensaje);

if(empty($nombre)) {
$error[] = $alerta[0];
}
if($email != "") {
if (!ereg("^[^@]+@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,}$", $email)) {
$error[] = $alerta[1];
}
}
if(empty($mensaje)) {
$error[] = $alerta[2];
}

// Filtro de malas palabras

if($FiltroGroserias == "SI") {
for($i = 0; $i < sizeof($palabrotas); $i++) {
if(ereg($palabrotas[$i], $nombre) OR ereg($palabrotas[$i], $email) OR ereg($palabrotas[$i], $mensaje)) {
$error[] = $alerta[3];
}
}
}

if($error) {

include("html/tpl_error.html");

} else {

// Filtramos el mensaje

HTML();
Remplazar();
$mensaje = ereg_replace("\r\n","<br>", $mensaje);

// Guardamos la firma en el fichero

$fp = fopen($FicheroId,"r");
$id = fread($fp, filesize($FicheroId));
$id ++;
fclose($fp);

$fp = fopen($FicheroId, "w");
fwrite($fp, $id);
fclose($fp);

$firma = "$id|@|$nombre|@|$email|@|$url|@|$mensaje|@|$fecha |@|\n";
$fp = fopen($FicheroBase, "a");
fwrite($fp, $firma);
fclose($fp);

Template("html/tpl_correcto.html");

}
break;
default:

// Mostrar todas las firmas

$Base = file($FicheroBase);
$Orden = array_reverse($Base);

if(empty($paginado)) {
$paginado = 0;
}

$Mostrar = $paginado + $LimiteMensajes;

for ($i = $paginado; $i < count($Orden) AND $i < $Mostrar; $i++) {
$dato = explode("|@|", $Orden[$i]);

$nombre = $dato[1];
$email = $dato[2];
$url = $dato[3];
$mensaje = $dato[4];
$fecha = $dato[5];

// Template

Template("html/tpl_mensajes.html");

}

echo "<table cellpadding='4' cellspacing='1' width='380' align='center' class='normal'>";
echo "<tr><td width='380'>";
Paginacion();
echo "</td><td width='380' align='right'>";
echo "<b><a href='index.php?accion=firmar'>Firmar libro</a></b>";
echo "</td></tr></table>";

}

Template("html/tpl_abajo.html");
?>