Foros del Web » Programando para Internet » PHP »

Actualizando datos [ No extrae valores ]

Estas en el tema de Actualizando datos [ No extrae valores ] en el foro de PHP en Foros del Web. Saludos, estoy diseñando un form para actualizar los datos y no me esta extrayendo los datos del usuario al iniciar session para asi poder actualizarlos ...
  #1 (permalink)  
Antiguo 19/06/2008, 11:54
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Actualizando datos [ No extrae valores ]

Saludos,

estoy diseñando un form para actualizar los datos y no me esta extrayendo los datos del usuario al iniciar session para asi poder actualizarlos en la BD.
Lo q deseo hacer es que el usuario pueda editar su perfil personal... pero no me extrae los campos..
aqui dejo ambos codigod
Código PHP:
<?php require_once('conect.php'); ?>
<?php
$rec 
"-1";
if (isset(
$_SESSION['id'])) {
  
$rec $_SESSION['id'];
}

$sql="select * from clientes where id = '$rec'";
        
$sql_exec mysql_query($sql);
        
$rec mysql_fetch_array($sql_exec);

@
$status=$_REQUEST['status'];
if (
$status==1) {
$msj="Perfil actualizado con éxito!";
}
if (
$status==2) {
$msj="- No se pudo procesar su modificación por errores en los cambios realizados";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
}
-->
</style>
<link href="../admin/css/estilo.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="4"><img src="img_x2/header_x2.jpg" width="600" height="140" /></td>
  </tr>
  <tr>
    <td height="200" rowspan="2" valign="top" background="img_x2/bg_x2.jpg"><table width="140" border="0" align="center" cellpadding="0" cellspacing="3">
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td width="27"><img src="img_x2/home_x2.jpg" width="19" height="19" /></td>
        <td width="104" class="textoResto">Inicio</td>
      </tr>
      <tr>
        <td height="5"></td>
        <td class="textoResto"></td>
      </tr>
      <tr>
        <td><img src="img_x2/usr_x2.jpg" width="18" height="18" /></td>
        <td class="textoResto"><a href="edt_perf_x2.php">Editar Perfil</a></td>
      </tr>
      <tr>
        <td></td>
        <td height="5" class="textoResto"></td>
      </tr>
      <tr>
        <td><img src="img_x2/ver_x2.jpg" width="18" height="18" /></td>
        <td class="textoResto">Ver facturas</td>
      </tr>
      <tr>
        <td height="5"></td>
        <td class="textoResto"></td>
      </tr>
      <tr>
        <td><img src="img_x2/ing_x2.jpg" width="18" height="18" /></td>
        <td class="textoResto">Ingresar facturas</td>
      </tr>
    </table></td>
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td width="27">&nbsp;</td>
    <td width="368" align="center" valign="middle" class="textoResto"><form id="form1" name="form1" method="post" action="includes/edita_perfil.php">
                <p class="azul_verd_nrm"><strong class="azulgrs_tah"><?=$msj?></strong><br /></p>
<table width="260" border="0" align="center" cellpadding="0" cellspacing="2">
                  <tr>
                    <td width="124" class="azulgrs_tah"><div align="right">Nombre: </div></td>
                    <td width="130" align="center"><label>
                      <input name="nombre" class="textoTitulos2" value="<?php echo htmlentities ($rec['nombre'], ENT_COMPAT'utf-8'); ?>" textype="text" cols="25" rows="5"/>
                    </label></td>
                  </tr>
                  <tr>
                    <td class="azulgrs_tah"><div align="right">Apellido:</div></td>
                    <td align="center"><label>
                    <input name="apellido" class="textoTitulos2" value="<?php echo $rec['apellido']; ?>" textype="text" cols="25" rows="5"/>
                    </label></td>
                  </tr>
                  <tr>
                    <td class="azulgrs_tah"><div align="right">C.I./RIF.:</div></td>
                    <td align="center"><input name="cedula" class="textoTitulos2" value="<?php echo $rec['cedula']; ?>" textype="text" cols="25" rows="5"/></td>
                  </tr>
                  <tr>
                    <td class="azulgrs_tah"><div align="right">Teléfono:</div></td>
  <td align="center"><label>
  <input name="telefono" class="textoTitulos2" value="<?php echo $rec['telefono']; ?>" textype="text" cols="25" rows="5"/>
  </label></td>
                  </tr>
                  <tr>
                    <td class="azulgrs_tah"><div align="right">E-Mail:</div></td>
                    <td align="center"><input name="mail" class="textoTitulos2" value="<?php echo $rec['mail']; ?>" textype="text" cols="25" rows="5"/></td>
                  </tr>
                  <tr>
                    <td class="azulgrs_tah"><div align="right">Fecha de Nacimiento:</div></td>
                    <td align="center"><input name="fecha" class="textoTitulos2" value="<?php echo $rec['fecha']; ?>" textype="text" cols="25" rows="5"/></td>
                  </tr>
                </table>
          <br />
<p align="center">
                  <label>
                  <input name="enviar" type="submit" class="textoResto" id="enviar" value="Enviar" />
                  </label>
        </p>
    </form></td>
    <td width="26" height="200">&nbsp;</td>
  </tr>
  <tr>
    <td width="179" background="img_x2/bg_x2.jpg"><img src="img_x2/bg_x2.jpg" width="179" height="10" /></td>
    <td colspan="3">&nbsp;</td>
  </tr>
  <tr>
    <td height="8" colspan="4" bgcolor="#E1AE00"></td>
  </tr>
</table>
</body>
</html>
y el include a donde apunta el form
Código PHP:
<?php
include ('../conect.php');
$date=date('Y-n-d G:i:s');
extract($_REQUEST);

$nombre $_REQUEST["nombre"];
$apellido $_REQUEST["apellido"];
$cedula $_REQUEST["cedula"];
$telefono $_REQUEST["telefono"];
$mail $_REQUEST["mail"];
$fecha $_REQUEST["fecha"];
          
            
                if (empty(
$errores)) {
                
$sql "UPDATE info SET
                nombre='$nombre',
                apellido = '$apellido',
                cedula = '$cedula',
                telefono = '$telefono',
                mail = '$mail',
                fecha = '$fecha'"
;
                       
                
mysql_query($sql);
                
header("Location: ../edit_perf_x2.php?status=1");
                }
                if (!empty(
$errores)){
                
header("Location: ../edit_perf_x2?status=2");
                }
?>
EDITO
fijense q extraigo de otra manera en el primer campo pues queria ver si ese era mi error

Código PHP:
<?php echo htmlentities ($rec['nombre'], ENT_COMPAT'utf-8'); ?>
Gracias
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #2 (permalink)  
Antiguo 19/06/2008, 12:09
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Actualizando datos [ No extrae valores ]

Hola T4ke0veR,

¿En donde defines $errores?, ya que tu comparas si no esta vacio, pero no la veo en ninguna parte definida.

Saludos.
  #3 (permalink)  
Antiguo 19/06/2008, 12:12
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Actualizando datos [ No extrae valores ]

tienes razon....
pero de igual manera... pq no se me muestran los datos para actualizar antes de hacerlo.. pues al codigo al q t refieres es cuando hago click para procesar...
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #4 (permalink)  
Antiguo 19/06/2008, 12:22
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Actualizando datos [ No extrae valores ]

Prueba hacer algo así:
Código PHP:
<?php
include ('../conect.php');
$date=date('Y-n-d G:i:s');
extract($_REQUEST);

$nombre $_REQUEST["nombre"];
$apellido $_REQUEST["apellido"];
$cedula $_REQUEST["cedula"];
$telefono $_REQUEST["telefono"];
$mail $_REQUEST["mail"];
$fecha $_REQUEST["fecha"];
          
$sql "UPDATE info SET
                nombre='$nombre',
                apellido = '$apellido',
                cedula = '$cedula',
                telefono = '$telefono',
                mail = '$mail',
                fecha = '$fecha'"
;
                       
$result mysql_query($sql) or die( "[ERROR] Query: $query, error: " mysql_error() );
if( 
$result ) {
      
header("Location: ../edit_perf_x2.php?status=1");
} else {
      
header("Location: ../edit_perf_x2?status=2");
}
?>
Saludos.
  #5 (permalink)  
Antiguo 19/06/2008, 12:45
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Actualizando datos [ No extrae valores ]

no me estas entendiendo .. =/
mi problema no es en el SET
mi problema es q
esto
Código PHP:
<?php require_once('conect.php'); ?> 
<?php 
$rec 
"-1"
if (isset(
$_SESSION['id'])) { 
  
$rec $_SESSION['id']; 


$sql="select * from clientes where id = '$rec'"
        
$sql_exec mysql_query($sql); 
        
$rec mysql_fetch_array($sql_exec); 

@
$status=$_REQUEST['status']; 
if (
$status==1) { 
$msj="Perfil actualizado con éxito!"

if (
$status==2) { 
$msj="- No se pudo procesar su modificación por errores en los cambios realizados"
}
?>
no me esta mostrando los datos a la hora de imprimirlos en el form.:.!!!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
  #6 (permalink)  
Antiguo 19/06/2008, 12:51
Avatar de T4ke0veR  
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 16 años, 8 meses
Puntos: 28
Respuesta: Actualizando datos [ No extrae valores ]

bueno ya soluciones... mi error estaba en
Código PHP:
<?php require_once('includes/sesion.php'); //aqui
require_once('conect.php'); ?>

<?php
/*
@$id=$_REQUEST['id'];

$query="SELECT * FROM clientes WHERE id= '$id'";
$sql_execex=mysql_query($query);
$datoscli=mysql_fetch_assoc($sql_execex);

*/

$reco "-1";
if (isset(
$_SESSION['id'])) {
  
$reco $_SESSION['id'];
}

$sql="select * from clientes where id = '$reco'";
        
$sql_exec mysql_query($sql);
        
$rec mysql_fetch_array($sql_exec);

?>
Gracias
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...
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 21:28.