Ver Mensaje Individual
  #144 (permalink)  
Antiguo 18/05/2010, 02:41
Avatar de Flow89
Flow89
 
Fecha de Ingreso: abril-2010
Ubicación: Valladolid
Mensajes: 346
Antigüedad: 14 años
Puntos: 1
Respuesta: Gestor de Noticias para HTML con PHP [novato]

Ahora el sistema de editar las noticias no me funciona, yo creo que esta todo correcto, por más que miro no encuentro ningun fallo... :S, te pongo los archivos.

editar.php
Código PHP:
<?
      
//recibimos la variable id enviada en el enlace por GET
      
$id=$_GET[id];
       include (
"conex.php");
      
//hacemos las consultas
      
$result=mysql_query("select * from noticias where id_noticia='$id'",$connect);
      
//Una vez seleccionados los registros los mostramos para su edición
      
while($row=mysql_fetch_array($result)) {
      echo 
"<div id=\"gnoticias\">
<table width=\"650\" border=\"0\" align=\"center\">
    <tr>
      <td colspan=\"2\"><div align=\"center\"><img src=\"../imagenes/panel.png\" width=\"500\" height=\"200\" /></div></td>
<tr>
    <td><div align=\"center\" class=\"Estilo16 Estilo40\">Edita una noticia | <a href='../loginpanel/administracion.php'> Volver </a></div></td>
  </tr>
<tr><td>
      <form action=\"edit.php\" method=\"post\">
      <input type=\"hidden\" name=\"id\" value=\""
.$row[id_noticia]."\">
<b>Título:</b><br>
<input type=\"text\" name=\"titulo\" value=\""
.$row[titulo]."\"><br>
<br><b>Autor:</b><br>
<input type=\"text\" name=\"autor\" value=\""
.$row[autor]."\"><br>
      <br><b>Categoría:</b><br>
      <input type=\"text\" name=\"categoria\" value=\""
.$row[categoria]."\"><br>
      <br><b>Escriba el articulo</b><br>
      <textarea name=\"noticia\" class=\"widgEditor\" cols=\"50\" rows=\"10\">\""
.$row[noticia]."\"</textarea>
      <br><input type=\"submit\" value=\"Guardar\" > <input name=\"restablecer\" type=\"reset\" id=\"restablecer\" value=\"Limpiar\" />
      </form>
</td></tr>
</table>"
;
      }
      
mysql_free_result($result);
      
mysql_close($connect);
      
?>
edit.php
Código PHP:
<?php
include("login.php");
if(
$loginCorrecto)
  { 
      
//recibimos las variables enviadas por el formulario
      
$id=$_POST[id_noticia];
      
$titulo=$_POST[titulo];
      
$autor=$_POST[autor];
      
$categoria=$_POST[categoria];
      
$noticia=$_POST[noticia];

    
    
//incluimos el archivo de conexion
    
include ("conex.php");

      
//modificamos los datos de la base según variables recibidas
      
mysql_query("update noticias Set noticia='$noticia',categoria='$categoria',titulo='$titulo' where id_noticia='$id'"$connect);
      
header("location: ../index.php");
}
__________________
Seamos realistas. Busquemos lo imposible. ;)
La forma de dar las gracias en este foro, es dando Karma, aunque a veces con un simple Gracias, basta.