Foros del Web » Programando para Internet » PHP »

Problema con PHP de GuestBook

Estas en el tema de Problema con PHP de GuestBook en el foro de PHP en Foros del Web. Hola, tngo un problema con un codigo para un Guestbook. Es para flash y modifica un archivo .txt, que despues se ve en el swf, ...
  #1 (permalink)  
Antiguo 05/12/2007, 12:10
 
Fecha de Ingreso: diciembre-2007
Mensajes: 2
Antigüedad: 16 años, 4 meses
Puntos: 0
Problema con PHP de GuestBook

Hola, tngo un problema con un codigo para un Guestbook.
Es para flash y modifica un archivo .txt, que despues se ve en el swf, lo modifique ya para que me aceptara los acentos. El problema que aun no logro hacer que reconozca los "enter". No puedo hacer puntos aparte en los comentarios.... y sin eso no podre subir el swf a la web..... Ojala me puedan ayudar...
El resto del cogido me funciona muy bien, no tengo mayores problemas, lo unico es lo de los espaciados.....

el codigo es el siguiente:

Cita:
<?php
// If you are using an old version of php, remove the next set of lines.
// or use $HTTP_POST_VARS["..."] instead.
$Submit = $_POST["Submit"];
$Name = $_POST["Name"];
$Email = $_POST["Email"];
$Website = $_POST["Website"];
$Comments = $_POST["Comments"];
$NumLow = $_REQUEST["NumLow"];
$NumHigh = $_REQUEST["NumHigh"];

// Replace special characters - you can remove the next 5 lines if wanted.
$Name = ereg_replace("[^A-Za-áéíóú¿?!¡z0-9 ]", "", $Name);
$Email = ereg_replace("[^A-Za-áéíóú¿?!¡z0-9 \@\.\-\/\']", "", $Email);
$Comments = ereg_replace("[^A-Za-áéíóú¿?!¡z0-9 \@\.\-\/\']", "", $Comments);
$Website = eregi_replace("http://", "", $Website);
$Website = ereg_replace("[^A-Za-áéíóú¿?!¡z0-9 \@\.\-\/\'\~\:]", "", $Website);

// Remove slashes.
$Name = stripslashes($Name);
$Email = stripslashes($Email);
$Website = stripslashes($Website);
$Comments = stripslashes($Comments);

// ################################################## #################################
// ########## Reading and Writing the new data to the GuestBook Database #############

if ($Submit == "Yes") {
// Next line tells the script which Text file to open.
$filename = "GuestBook.txt";

// Opens up the file declared above for reading

$fp = fopen( $filename,"r");
$OldData = fread($fp, 80000);
fclose( $fp );

// Gets the current Date of when the entry was submitted
$Today = (date ("l dS of F Y ( h:i:s A )",time()));

// Puts the recently added data into html format that can be read into the Flash Movie.
// You can change this up and add additional html formating to this area. For a complete listing of all html tags
// you can use in flash - visit: http://www.macromedia.com/support/flash/ts/documents/htmltext.htm

$Input = "Nombre: <b>$Name</b><br>Generacion: <b>$Website</b><br>Comentario: <b>$Comments</b><br><i><font size=\"-1\">Fecha: $Today</font><br><br>.:::.<b>--------------------------------------------<br>";

/* This Line adds the '&GuestBook=' part to the front of the data that is stored in the text file. This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file */

$New = "$Input$OldData";

// Opens and writes the file.

$fp = fopen( $filename,"w");
if(!$fp) die("&GuestBook=cannot write $filename ......&");
fwrite($fp, $New, 800000);
fclose( $fp );
}

// ################################################## #################################
// ######### Formatting and Printing the Data from the Guestbook to the Flash Movie ##



// Next line tells the script which Text file to open.
$filename = "GuestBook.txt";

// Opens up the file declared above for reading

$fp = fopen( $filename,"r");
$Data = fread($fp, 800000);
fclose( $fp );

// Splits the Old data into an array anytime it finds the pattern .:::.
$DataArray = split (".:::.", $Data);

// Counts the Number of entries in the GuestBook
$NumEntries = count($DataArray) - 1;

print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh= $NumHigh&GuestBook=";
for ($n = $NumLow; $n < $NumHigh; $n++) {
print $DataArray[$n];
if (!$DataArray[$n]) {
Print "<br><br><b>No More entries</b>";
exit;
}
}
?>
  #2 (permalink)  
Antiguo 05/12/2007, 13:19
 
Fecha de Ingreso: diciembre-2007
Mensajes: 2
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Problema con PHP de GuestBook

porfavor ayuda..... es muy impiortante :(
  #3 (permalink)  
Antiguo 02/01/2008, 18:02
Avatar de eggon  
Fecha de Ingreso: enero-2008
Mensajes: 1
Antigüedad: 16 años, 3 meses
Puntos: 0
Re: Problema con PHP de GuestBook

yo tuve ese problema pero con HTML ya hace tiempo y la funcion nl2br de php hace que respete los "enter".

y no se te olvide en el flash poner System.useCodepage = true;

a mi lo que me hacía en flash era mostrar un "enter" como doble, y se veia muy espaciado el texto, tuve que hacer unos reemplazos en php.

Suerte y si lo resolviste ya o lo resuelves me dices si te funciono.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:03.