Ver Mensaje Individual
  #5 (permalink)  
Antiguo 08/05/2006, 10:04
Vhyll
 
Fecha de Ingreso: octubre-2004
Ubicación: Lima, Perú
Mensajes: 185
Antigüedad: 19 años, 6 meses
Puntos: 1
SI tu noticias lo utilizas con ind noticia.php?id=23
Solo reemplazas el las lineas en el codigo que mandastes
Código PHP:
<?
// Conectamos a la base de datos
// Pero verifiquen que no tengan una conexión ya
// Abierta en la página que muestre sus noticias
// Pues este fichero va a ser incluido en ella.
$cnx mysql_connect('localhos','usuario','pass');
mysql_select_db('nombre_base_datos',$cnx);
//-------------------------------------------------

// Si el formulario fue enviado, lo procesamos.
if (isset($_POST['enviar'])) {
    
// Si el comentario existe:
    
if (isset($_POST['comentario'])) {
        
// Si el nombre del autor no fue agregado
        // colocaremos por default: Anónimo.
        
if ($_POST['autor'] == "") { $autor 'Anónimo'; }
        else { 
$autor $_POST['autor']; }
        
        
$ip $REMOTE_ADDR;
        
// Arreglamos el comentario para que no
        // tenga etiquetas HTML.
        
$comentario htmlspecialchars($_POST['comentario']);
        
$comentario addslashes($comentario);
        
        
mysql_query("INSERT INTO comentarios  (id_padre, autor, ip, comentario) values ('".addslashes($_POST['id_padre'])."', '".addslashes($_POST['autor'])."', '".addslashes($_POST['ip'])."', '".addslashes($_POST['comentario'])."')");
    
    } else { 
$msg 'Debe agregar un Comentario'; }
}

// Pedimos todos los comentarios cuyo id_padre
// coincida con el id de la noticia.
$sql mysql_query("SELECT * FROM comentarios WHERE id_padre='".$_GET["id"]."' order by id ASC");
?>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td>            <table width="100%"  border="0" cellspacing="0" cellpadding="2">
              <tr>
                <td><div align="center"><strong>Comentarios</strong></div></td>
              </tr>
              <tr>
                <td>
  <?
while ($datos mysql_fetch_array($sql)) {
//Arreglamos el comentario --------------------------
$comentario $datos[comentario];
$comentario stripslashes($comentario);
//---------------------------------------------------
?>              <div align="center">
                  <table width="97%" border="1" cellspacing="0" cellpadding="0">
                    <tr>
                      <td><strong>Nombre:</strong> <?=$datos[nombre]?></td>
                    </tr>
                    <tr>
                      <td><b>Comentario:</b><br><?=$comentario?></td>
                    </tr>
                  </table>
                  <br>
  <? ?>
                </div></td>
              </tr>
          </table></td></tr>
        <tr>
          <td>
          
          <!-- AQUI EMPIEZA EL FORMULARIO QUE AGREGA LOS COMENTARIOS -->
          <form action="<?=$PHP_SELF?>" method="post">
          <table width="100%"  border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td colspan="2"><div align="center"><strong>Agrega tu Comentario</strong></div></td>
            </tr>
            <tr>
              <td width="40%"><div align="center"><strong>Nombre:</strong></div></td>
              <td width="60%"><div align="center"><input type="text" name="autor"></div></td>
            </tr>
            <tr>
              <td><div align="center"><strong>Comentario:</strong></div></td>
              <td><div align="center"><textarea name="comentario" cols="50" rows="7"></textarea>
              </div></td>
            </tr>
          </table>
          <div align="center">
            <p>
            </p>
<input type="submit" name="enviar" value="Enviar">
            </div>
          </form>          </td>
        </tr>
      </table>