Ver Mensaje Individual
  #6 (permalink)  
Antiguo 04/11/2010, 21:07
Avatar de ylellan
ylellan
 
Fecha de Ingreso: mayo-2010
Ubicación: en un lugar de Veracruz
Mensajes: 432
Antigüedad: 14 años
Puntos: 36
Respuesta: Editar cualquier registro de la base de datos con un solo archivo mediante

mira un ejemplo copiando el codigo de dcreate:

index.php
<html>
<head><title></title></head>
<body>
<?php echo $_GET['comentario'];?>
<form action="editar.php" method="post">
buscar:<input type="text" name="id"><br>
<input type="submit" name="buscar">
</form>
</body>
</html>


editar.php
Código PHP:
<html> 
<head><title></title></head> 
<body> 
<?php  
if(isset($_POST['buscar'])) 

$id=$_POST['id']; 
include 
"conexion.php"
conectar(); 
$b=mysql_query("select *from tabla where id='$id'") or die("error".mysql_error()); 
$con=mysql_fetch_array($b); 
$existe=mysql_num_rows($b);
if(
$existe>0)
{
echo 
'<form action="editar.php" method="post">'
echo 
'nombre:<input type="text" name="nombre" value="'.$con['nombre'].'"><input type="hidden" name="id" value="'.$con['id'].'"><br>'
echo 
'<input type="submit" name="guardar" value="guadar">'
echo 
'</form>'
}else{
echo 
'<script>alert("no se encuentra el dato");history.back(-1);</script>':
}

?> 
<?php 
if(isset($_POST['guardar'])) 

$id=$_POST['id']; 
$nombre=$_POST['nombre']; 
mysql_query("UPDATE tabla SET nombre='$nombre' WHERE id='$id'") or die("error".mysql_error()); 
header("location:index.php?comentario=grabado_con_exito");

//yo pondria un desconectar o cerrar la conexion
mysql_close();
?> 
</body> 
</html>
encontre muchos errores de dcreate