Ver Mensaje Individual
  #6 (permalink)  
Antiguo 31/08/2009, 03:39
AnimalRecord
 
Fecha de Ingreso: agosto-2009
Mensajes: 7
Antigüedad: 14 años, 8 meses
Puntos: 0
Respuesta: Actualizar Datos con Formulario y MySQL

Hola,

Sigo en el mismo problema, he cambiado GET por POST, pero es como si siguiese sin cogerme los datos de la tabla.

Ahi va:

ficha_clientes.php

Código PHP:
<form id="modificar" name="modificar" method="post" action="modificar_cliente.php">
<td>
  <?php 
    
if (mysql_num_rows($resultado2)==0){ echo "No hay resultados";} // num rows pregunta si se ha enviado alguna fila, por eso indicamos si es=0//
    
while ($fila=mysql_fetch_array($resultado2)) {
    
?>
  <tr>
    <td width="50%" height="414" bordercolor="#000000"><div class="nombre" align="left">
      <table width="default" border="3" bordercolor="#000000" bgcolor="#FFFF99">
        <tr>
          <td><strong>IdCliente:</strong></td>
          <td><input type="text" name="IdCliente" id="IdCliente" size="5" maxlength="5" value="<?php echo $fila["IdCliente"];?>"></td>
        </tr>
        <tr>
          <td><strong>DNI/CIF:</strong></td>
          <td><input type="text" name="DNICIF" id="DNICIF" size="10" maxlength="10" value="<?php echo $fila["DNICIF"];?>"></td>
        </tr>
        <tr>
          <td><strong>Contrase&ntilde;a:</strong></td>
          <td><input type="text" name="Contrasena" id="Contrasena" size="16" maxlength="16" value="<?php echo $fila["Contrasena"];?>"></td>
        </tr>
        <tr>
          <td><strong>Nombre:</strong></td>
          <td><input type="text" name="Nombre" id="Nombre" size="20" maxlength="20" value="<?php echo $fila["Nombre"];?>"></td>
        </tr>
        <tr>
          <td><strong>Apellidos:</strong></td>
          <td><input type="text" name="Apellidos" id="Apellidos" size="20" maxlength="20" value="<?php echo $fila["Apellidos"];?>"></td>
        </tr>
        <tr>
          <td><strong>Empresa:</strong></td>
          <td><input type="text" name="Empresa" id="Empresa" size="30" maxlength="30" value="<?php echo $fila["Empresa"];?>"></td>
        </tr>
        <tr>
          <td><strong>Direcci&oacute;n:</strong></td>
          <td><input type="text" name="Direccion" id="Direccion" value="<?php echo $fila["Direccion"];?>"></td>
        </tr>
        <tr>
          <td><strong>Poblaci&oacute;n:</strong></td>
          <td><input type="text" name="Poblacion" id="Poblacion" size="30" maxlength="30" value="<?php echo $fila["Poblacion"];?>"></td>
        </tr>
        <tr>
          <td><strong>Provincia:</strong></td>
          <td><input type="text" name="Provincia" id="Provincia" size="30" maxlength="30" value="<?php echo $fila["Provincia"];?>"></td>
        </tr>
        <tr>
          <td><strong>C.P.:</strong></td>
          <td><input type="text" name="CP" id="CP" size="5" maxlength="5" value="<?php echo $fila["CP"];?>"></td>
        </tr>
        <tr>
          <td><strong>Email:</strong></td>
          <td><input type="text" name="Email" id="Email" size="30" maxlength="30" value="<?php echo $fila["Email"];?>"></td>
        </tr>
        <tr>
          <td><strong>Tel&eacute;fono:</strong></td>
          <td><input type="text" name="Telefono" id="Telefono" size="9" maxlength="9" value="<?php echo $fila["Telefono"];?>"></td>
        </tr>
        <tr>
          <td><strong>Fecha de Alta:</strong></td>
          <td><input type="text" name="FechaAlta" id="FechaAlta" size="20" maxlength="20" value="<?php echo $fila["FechaAlta"];?>"></td>
        </tr>
        <tr>
          <td><input name="modificar" type="submit" id="modificar" value="modificar"></td>
          </tr>
      </table>
     <p>&nbsp;</p>
     <?php ?>
</form>
modificar_cliente.php

Código PHP:
<?php

$_POST
["IdCliente"];
$_POST["DNICIF"];
$_POST["Contrasena"];
$_POST["Nombre"];
$_POST["Apellidos"];
$_POST["Empresa"];
$_POST["Direccion"];
$_POST["Poblacion"];
$_POST["Provincia"];
$_POST["CP"];
$_POST["Email"];
$_POST["Telefono"];
$_POST["FechaAlta"];



include (
"conectar.inc.php"); // incluye base de datos
$sql="update clientes set IdCliente='".$_POST['$IdCliente']."', DNICIF='".$_POST['$DNICIF']."', Contrasena='".$_POST['$Contrasena']."', Nombre='".$_POST['$Nombre']."', Apellidos='".$_POST['$Apellidos']."', Empresa='".$_POST['$Empresa']."', Direccion='".$_POST['$Direccion']."', Poblacion='".$_POST['$Poblacion']."', Provincia='".$_POST['$Provincia']."', CP='".$_POST['$CP']."', Email='".$_POST['$Email']."', Telefono='".$_POST['$Telefono']."', FechaAlta='".$_POST['$FechaAlta']. "' where IdCliente='".$_POST['$IdCliente']."'";// // Direccion='$Direccion', Poblacion='$Poblacion', Provincia='$Provincia', CP='$CP', Email='$Email', Telefono='$Telefono' where IdCliente='$IdCliente'";// modifica registros de la tabla
 
$resultado mysql_query($sql);
  if (
$resultado)
  {
      echo  
"Cliente Modificado.";
     }
else {
echo 
"Error";
}

?>
Gracias por la ayuda.