me hice un blog yo solo, en unos de los hice un módulo para editar los post que agrego. el código es el siguiente:
Código PHP:
<?
/**
* MODULO EDITAR POST
* ------------------
* Este modulo permite editar un post seleccionado
*/
/**
* busco el post en la db según el id que me pasa el formulario
*/
$sql="SELECT * FROM post WHERE id_post='".$_GET['id']."'";
$result=mysql_query($sql);
$row = mysql_fetch_array ($result);
?>
<div><h2>Administración de Post</h2></div>
<div align="center"><h4>Editar Post</h4></div>
<div align="center">
<form method="post" action="?mod=post_editar&op=guardar">
<table cellspacing="5" cellpadding="3">
<tr>
<td><b>Titulo:</b></td>
</tr>
<tr>
<td>
<input type="hidden" name="id_post" value="<? echo $row['id_post']?>" />
<input name="titulo" type="text" id="titulo" size="50" value="<? echo $row['titulo']?>"/>
</td>
</tr>
<tr>
<td><b>Categoría:</b></td>
</tr>
<tr>
<td>
<input name="categoria" type="text" id="categoria" size="50" value="<? echo $row['categoria']?>"/>
</td>
</tr>
<tr>
<td colspan="2"><div align="left"><b>Texto Noticia:</b></div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<textarea name="texto" cols="80" rows="10" id="texto"><? echo $row['texto']?></textarea>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="left"><b>Texto Extendido:</b></div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<textarea name="textoa" cols="80" rows="10" id="textoa"><? echo $row['texto_a']?></textarea>
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<label>
<input type="submit" name="Submit" value="Enviar" />
</label>
</div></td>
</tr>
</table>
</form>
<br/><br/>
</div>
<?
switch ($_GET['op']){
case "guardar":
guardar();
break;
}
/**
* SECCION DONDE DECLARO LAS FUNCIONES PARA GUARDAR LOS DATOS EDITADOS
*
*/
function guardar(){
$id_post=$_POST["id_post"];
$titulo=$_POST["titulo"];
$texto=$_POST["texto"];
$textoa=$_POST["textoa"];
$categoria=$_POST["categoria"];
/*$sql="UPDATE `blog`.`post` SET `titulo`='$titulo' ,`texto`='$texto' ,`texto_a`='$textoa' ,
`categoria`='$categoria' WHERE `post`.`id_post`='$id_post'";
$result=mysql_query($sql);*/
$sql="UPDATE `post` SET `titulo`='$titulo' ,`texto`='$texto' ,`texto_a`='$textoa' ,
`categoria`='$categoria' WHERE `id_post`='$id_post'";
$result=mysql_query($sql);
if ($result==true){
echo "Se guardaron los datos correctamente";
echo'<div><center><a href="?mod=cpanel">volver al menú principal</a></center></div>';
}
else{
echo "No se pudieron guardar los datos correctameten.... intentelo otra vez";
echo'<div><center><a href="?mod=cpanel">volver al menú principal</a></center></div>';
}
}
?>
Notice: Undefined index: op in D:\xampp\htdocs\blog\modulos\post_editar.php on line 66
el link que uso es este:
http://localhost/blog/?mod=post_editar&id=8
como puedo hacer para que no salga este error?
desde ya muchas gracias