Foros del Web » Programando para Internet » PHP »

UPdate de registro

Estas en el tema de UPdate de registro en el foro de PHP en Foros del Web. tengo este codigo y tengo un formulario de UPdate y con esto hay que volver a subir la imagen cada ves que se actualice , ...
  #1 (permalink)  
Antiguo 09/12/2010, 22:09
 
Fecha de Ingreso: junio-2010
Mensajes: 128
Antigüedad: 13 años, 10 meses
Puntos: 2
UPdate de registro

tengo este codigo

y tengo un formulario de UPdate y con esto hay que volver a subir la imagen cada ves que se actualice , quiero que si no se elije otra imagen quede la que fue designada , como puedo hacer gracias!!!!!!!

Código PHP:

<?php require_once('../Connections/localhost.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_update"])) && ($_POST["MM_update"] == "formulario")) {
  
$updateSQL sprintf("UPDATE noticias SET fecha=%s, fechanac=%s, titulo=%s, detalle=%s, foto='fotos/{$_FILES['foto']['name']}', nota=%s, ubicacion=%s, categoria=%s WHERE id=%s",
                       
GetSQLValueString($_POST['fecha'], "date"),
                       
GetSQLValueString($_POST['fechanac'], "date"),
                       
GetSQLValueString($_POST['titulo'], "text"),
                       
GetSQLValueString($_POST['detalles'], "text"),
                     
                       
GetSQLValueString($_POST['nota'], "text"),
                       
GetSQLValueString($_POST['ubicacion'], "text"),
                       
GetSQLValueString($_POST['categoria'], "text"),
                       
GetSQLValueString($_POST['id'], "int"));
                       
                        
$path="../fotos/";
            
            
            

                
                       
                       
                       if (
is_uploaded_file($_FILES['foto']['tmp_name'])) {
                          
move_uploaded_file($_FILES['foto']['tmp_name'], $path $_FILES['foto']['name']);
                          echo 
'La imagen '; echo $_FILES['foto']['name']. ' fue correctamente cargada!';
                          }

  
mysql_select_db($database_localhost$localhost);
  
$Result1 mysql_query($updateSQL$localhost) or die(mysql_error());

  
$updateGoTo "acceso.php";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$updateGoTo .= (strpos($updateGoTo'?')) ? "&" "?";
    
$updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$updateGoTo));
}

$colname_menu "1";
if (isset(
$_GET['id'])) {
  
$colname_menu = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_localhost$localhost);
$query_menu sprintf("SELECT * FROM noticias WHERE id = %s ORDER BY id DESC"$colname_menu);
$menu mysql_query($query_menu$localhost) or die(mysql_error());
$row_menu mysql_fetch_assoc($menu);
$totalRows_menu mysql_num_rows($menu);


                       
                       

?>
  #2 (permalink)  
Antiguo 12/12/2010, 07:35
 
Fecha de Ingreso: enero-2010
Ubicación: Colombia
Mensajes: 238
Antigüedad: 14 años, 2 meses
Puntos: 2
Respuesta: UPdate de registro

Tienes que dejar el campo imagen como predeterminado haciendo una consulta sql para que la imagen no pierda el valor.
Por ejemplo, yo lo haria de esta manerA:
Supongamos que tengo un formulario con nombres, apellidos y telefono del usuario, el cual quiere actualizar sus datos:


<input type="text" name="nombres" value=<?echo "$row->nombres"; ?> >
<input type="text" name="apellidos" value=<?echo "$row->apellidos"; ?> >
<input type="text" name="telefono" value=<?echo "$row->telefono"; ?> >

De esta manera los datos van a pervalecer en el formulario con el value predeterminado por cada usuario y asi no se va a perder la informacion,.

Es una idea, no se si te funcione de esta manera: Suerte
  #3 (permalink)  
Antiguo 13/12/2010, 08:03
 
Fecha de Ingreso: junio-2010
Mensajes: 128
Antigüedad: 13 años, 10 meses
Puntos: 2
Respuesta: UPdate de registro

claro Nelson es lo que hago pero me carga el campo vacio !!

yo pongo asi

Cita:

<dd>
<input name="foto" type="file" id="foto" value="<?php echo $row_menu['foto']; ?>" />
</dd>

Etiquetas: registro, update
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 02:19.