Foros del Web » Programando para Internet » PHP »

Que estoy haciendo mal?

Estas en el tema de Que estoy haciendo mal? en el foro de PHP en Foros del Web. Buenas noches a todos, ya le he dado muchas vueltas al codigo pero no se en que ando mal, es lo siguiente: mando una variable ...
  #1 (permalink)  
Antiguo 19/05/2012, 05:25
 
Fecha de Ingreso: noviembre-2011
Ubicación: Paris
Mensajes: 450
Antigüedad: 12 años, 5 meses
Puntos: 7
Que estoy haciendo mal?

Buenas noches a todos, ya le he dado muchas vueltas al codigo pero no se en que ando mal, es lo siguiente: mando una variable a otra pagina para hacer un UPDATE, en la otra pagina si me aparece todo bien, no me sale error ni nada pero al momento de darle enviar no se actualizan ;c quisiera ver que es el error, POR FAVOR!

Código PHP:
 <td width="25"><a href="editar.php?edit='.$row[0].'"><img src="iconos/Edit_64.png" width="25" height="25" /></a></td


Código PHP:
      <?php

     
include "config.php";
     if (!isset(
$accion)){
     
         
//Aqui es donde tomamos el id que nos mandan de la pagina anterior para hacer una seleccion y modificar los
         //valores de ese id
        
$result=mysql_query("SELECT * FROM articulos WHERE id=$edit"$conexion);
        
$row=mysql_fetch_array($result);
        
        

        
                      
                      
                    echo
'<td height="30"><form action="editar.php?accion=guardar" method="POST">
                          <label for="isbn">Isbn</label>
                          <input name="isbn" type="text" id="isbn" value="<?php echo $row[1]; ?>"size="40" />
                        </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="nomb_art">Nombre del Articulo</label>
                          <input name="nomb_art" type="text" id="nomb_art" value="<?php echo $row[2]; ?>" size="30" />
                      </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="autor_art">Autor</label>
                          <input name="autor_art" type="text" id="autor_art" value="<?php echo $row[3]; ?>" size="40" />
                      </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="fecha_pub">Fecha de publicacion</label>
                          <input name="fecha_pub" type="text" id="fecha_pub" value="<?php echo $row[4]; ?>" size="40" />
                       </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="desc_art">Descripcion</label>
                          <input name="desc_art" type="text" id="desc_art" value="<?php echo $row[5]; ?>" size="40" />
                       </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="abstract">Trata</label>
                          <input name="abstractf" type="text" id="abstractf" value="<?php echo $row[6]; ?>" size="40" />
                       </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="entidad_pub">Entidad  publica</label>
                          <input name="entidad_pub" type="text" id="entidad_pub" value="<?php echo $row[7]; ?>" size="40" />
                      </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="precio_art">Precio</label>
                          <input name="precio_art" type="text" id="precio_art" value="<?php echo $row[8]; ?>" size="40" />
                       </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="clave_busq">Clave</label>
                          <input name="clave_busq" type="text" id="clave_busq" value="<?php echo $row[9]; ?>" size="40" />
                       </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="pais_pub">Publicado </label>
                          <input name="pais_pub" type="text" id="pais_pub" value="<?php echo $row[10]; ?>" size="40" />
                       </td>
                      </tr>
                      <tr>
                        <td height="30">
                          <label for="archivo">Archivo</label>
                          <input name="archivo" type="file" id="archivo" size="40" />
                       </td>
                      </tr>
                      <tr>
                        <td height="30">
                        
                           <input type="hidden" name="id" value="'
.$row[0].'">
                          <input type="submit" name="enviar" id="enviar" value="Enviar" />
            
                        </form></td>    
                      </tr>'
;
                    
                        }
                        
                        
                        
            
                        
                         elseif(
$accion=="guardar"){
     

     
$a=$_POST["isbn"];
     
$b=$_POST["nomb_art"];
     
$c=$_POST["autor_art"];
     
$d=$_POST["fecha_pub"];
     
$e=$_POST["desc_art"];
     
$f=$_POST["abstractf"];
     
$g=$_POST["entidad_pub"];
     
$h=$_POST["precio_art"];
     
$i=$_POST["clave_busq"];
     
$j=$_POST["pais_pub"];
     
       
$result=mysql_query("UPDATE articulos SET isbn='$a',nomb_art='$b',autor_art='$c',fecha_pub='$d',desc_art='$e',abstract='$f',entidad_pub='$g',precio_art='$h',clave_busq='$i',pais_pub='$j' WHERE id=$edit"$conexion);
      
        echo
' <html>
         <head>  
        <script language="JavaScript" type="text/javascript">
alert("El registro ha sido actualizado exitosamente!");
</script>
         
         </head>
         <body>
    
         </html>'
;
         
         
         
    }
                        
                        
?>
  #2 (permalink)  
Antiguo 19/05/2012, 05:33
Avatar de Nemutagk
Colaborador
 
Fecha de Ingreso: marzo-2004
Ubicación: México
Mensajes: 2.633
Antigüedad: 20 años
Puntos: 406
Respuesta: Que estoy haciendo mal?

o.O como pretendes que se guarde si la variable $accion no esta definida? jamas va a entrar en el else if... en todo caso deberías hacer un...
Código PHP:
Ver original
  1. <?php
  2.  
  3.      include "config.php";
  4.      $accion = $_GET['accion'];
  5.      if (!isset($accion)){
__________________
Listo?, tendría que tener 60 puntos menos de IQ para considerarme listo!!!
-- Sheldon Cooper
http://twitter.com/nemutagk
PD: No contestaré temas vía mensaje personal =)
  #3 (permalink)  
Antiguo 19/05/2012, 05:41
 
Fecha de Ingreso: noviembre-2011
Ubicación: Paris
Mensajes: 450
Antigüedad: 12 años, 5 meses
Puntos: 7
Respuesta: Que estoy haciendo mal?

Gracias Nemutagk, pues ya la he puesto pero no me funciona, sigue igual :C
  #4 (permalink)  
Antiguo 19/05/2012, 05:44
Avatar de Nemutagk
Colaborador
 
Fecha de Ingreso: marzo-2004
Ubicación: México
Mensajes: 2.633
Antigüedad: 20 años
Puntos: 406
Respuesta: Que estoy haciendo mal?

No me había fijado, pero estas enviado el formulario como POST, lo mas recomendable es que crees un input del tipo hidden y hay especifiques la variable "accion", ya que da problemas el intentar enviar una variable get junto con una petición post, mejor envia todo de la misma forma...
__________________
Listo?, tendría que tener 60 puntos menos de IQ para considerarme listo!!!
-- Sheldon Cooper
http://twitter.com/nemutagk
PD: No contestaré temas vía mensaje personal =)
  #5 (permalink)  
Antiguo 19/05/2012, 05:51
 
Fecha de Ingreso: noviembre-2011
Ubicación: Paris
Mensajes: 450
Antigüedad: 12 años, 5 meses
Puntos: 7
Respuesta: Que estoy haciendo mal?

Ya lo tiene y tampoco :s
  #6 (permalink)  
Antiguo 19/05/2012, 05:53
 
Fecha de Ingreso: noviembre-2011
Ubicación: Paris
Mensajes: 450
Antigüedad: 12 años, 5 meses
Puntos: 7
Respuesta: Que estoy haciendo mal?

Gracias amigo, lo he conseguido!!

Etiquetas: haciendo, html, registro, sql, variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:58.