Ver Mensaje Individual
  #15 (permalink)  
Antiguo 18/09/2011, 07:25
edyuin
(Desactivado)
 
Fecha de Ingreso: septiembre-2011
Mensajes: 283
Antigüedad: 12 años, 7 meses
Puntos: 10
Respuesta: Sistema de comentarios php error archivo borrar

Nada no hay manera mira he hecho lo que mas dixo:

conect.inc
Código PHP:
<?php 

  
$bdconex 
= @mysql_connect("localhost""root"""); 
if (!
$bdconex) { 
echo( 
"<h1>La base de datos no está disponible</h1> " 
"<p>Por si acaso, comprueba que tienes bien los datos de la dirección, el nombre de usuario y la contraseña.</p>" ); 
exit(); 
}
 if (! @
mysql_select_db("iu"$bdconex)){
 echo 
"<h2 align='center'>ERROR3: Imposible localizar la base de datos en este momento</h2>";
 exit();
 }
 
?> 
<?php
 
  
$resultado 
= @mysql_query("SELECT * FROM comentarios order by fecha desc, id desc");
 if (!
$resultado) {
 echo (
"<p> Me temo que te has colado en la query:" mysql_error() . "</p>");
 exit();
 }
 while (
$fila mysql_fetch_array($resultado)) {
 
echo (
"<strong>Nombre: </STRONG>" $fila['nombre'] . "<br />");
echo (
"<strong>Email: </STRONG>" $fila['email'] . "<br />");
echo (
"<strong>Id: </STRONG>" $fila['id'] . "<br />");
 echo (
"<strong>Comentario:</strong>" $fila['comentario'] . "<br />");
echo (
"<strong>Fecha: </STRONG>" $fila['fecha'] . "<br/>");

 
?>

 <form action="borrar.php" method="post">
<input type="hidden" name="id" value="<?php echo $fila['id']; ?>"/>
<input type="submit" name="Submit" value="borrar">
</form>


<br/>
<?php ?>
este es el borrar.php
Código PHP:
<?


 
//recibimos la variable $id 
 
$id=$_POST['id']; 
 
//conectamos a la base 
 
$connect=mysql_connect("localhost","root",""); 
 
//Seleccionamos la base 
 
mysql_select_db("iu",$connect); 
 
//borramos los registros pertenecientes a la id 
mysql_query("delete * from comentarios where id='$id'",$connect);
 
header("location: index.php"); 
 
?>
y el frmulario que manda los comentarios
Código PHP:
<form id="comentarios" action="../insercomentario.php" method="post" ><table>
 <
tr>
 <
td>Nombre:</td>
 <
td><input name="nombre" type="text" value="Admin" /></td>
 </
tr>
 <
tr>
 <
td>E-mail</td>
 <
td><input name="email" type="text" value="[email protected]/></td>
 </
tr>
 <
tr>
 <
td>Comentraio:</td>
 <
td><textarea name="comentario"></textarea></td>
 </
tr>
 <
tr>
 <
td></td>
 <
td><input type="submit" name="accion" value="Comentar"></td>
 </
tr>
 </
table></form>
 <
table
Nose que es lo que falla, resulta que si mando ese formulario por get la direccion de arriba me manda todo esto mira:
http://localhost/iuyuncos/iu/admin/borrar.php?id=12&Submit=borrar

Yo solo quiero que mande el id y asi si se borraría no es cierto??
Como lo ago??
Muchas gracias.

Última edición por edyuin; 18/09/2011 a las 07:47