Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/05/2007, 05:44
Avatar de vb2005
vb2005
 
Fecha de Ingreso: noviembre-2005
Ubicación: Paderborn - Alemania
Mensajes: 568
Antigüedad: 18 años, 10 meses
Puntos: 25
Re: !!!!!!!!!!!Como crear un tagboard (minichat)

Aca te dejo uno que hice un poco al vuelo, si tiene errores sa razonable, tengo resaca de ayer :P y lo hice más que nada en 5 minutos

Código PHP:
<table width="100%" height="100%">
<?php
        $file 
"comments.txt";//archivo        
        
function form_validate () {
                
                if (
sizeof($_POST) < 1) return false;
                
                foreach (
$_POST as $name => $value) {
                        if (empty(
$name) || !isset($name)) {
                                return 
false;
                        }            
                }
                return 
true;
        }
        
        function 
blank_replace ($str) {
                return 
str_replace (" ","|",$str);
        }
        
        function 
stick_escape ($str) {
                return 
str_replace ("|"," ",$str);
        }


        if (
form_validate()) {
                    
                
$fp fopen ($file,"at");
                
fwrite ($fp,uniqid(rand(),true)."\t".blank_replace($_POST['name'])."\t".blank_replace($_POST['comment'])."\n");
                
fclose ($fp);                        
        }

        if (!
file_exists($file)) {
                echo 
"No hay comentarios";
        } else {

                
$fp fopen ($file,"r");
        
                while (
$info fscanf ($fp,"%s\n%s\n%s\n\n")) {        
                        list (
$id,$name,$comment) = $info;
?>

<table border="1" width="47%">
  <tr>
    <td width="26%">Nombre : </td>
    <td width="74%"><?=stick_escape($name)?></td>
  </tr>
  <tr>
    <td width="26%">Comentario:</td>
    <td width="74%"><?=stick_escape($comment)?></td>
  </tr>
</table>
<br>

<?php        
                
}        
        }

?>


<hr>

<form action="index.php" method="post">
Nombre:
<br>
<input name="name" type="text" size="30">
<br>
Comentario:
<br>
<textarea cols="30" name="comment"> </textarea>
<br>
<input type="submit" value="Submit">
</form>
</table>