Código PHP:
<?php require_once('Connections/hoysale.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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"] == "form1")) {
//Guardar imagen
if(is_uploaded_file($_FILES['Imagen']['tmp_name'])) { // verifica haya sido cargado el archivo
$ruta= "imagenesdeusuarios/".$_FILES['Imagen']['name'];
move_uploaded_file($_FILES['Imagen']['tmp_name'], $ruta);
}
$updateSQL = sprintf("UPDATE registrarse SET imagen=%s WHERE id_user=%s",
GetSQLValueString($ruta, "text"),
GetSQLValueString($_POST['id_user'], "int"));
mysql_select_db($database_hoysale, $hoysale);
$Result1 = mysql_query($updateSQL, $hoysale) or die(mysql_error());
$updateGoTo = "subio.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_Recordset1 = "-1";
if (isset($_SESSION['MM_id_user'])) {
$colname_Recordset1 = $_SESSION['MM_id_user'];
}
mysql_select_db($database_hoysale, $hoysale);
$query_Recordset1 = sprintf("SELECT * FROM registrarse WHERE id_user = %s", GetSQLValueString($colname_Recordset1, "int"));
$Recordset1 = mysql_query($query_Recordset1, $hoysale) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
mysql_free_result($Recordset1);
?>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Imagen:</td>
<td><input name="Imagen" type="file" id="Imagen" value="<?php echo htmlentities($row_Recordset1['imagen'], ENT_COMPAT, ''); ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Actualizar registro"></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="id_user" value="<?php echo $row_Recordset1['id_user']; ?>">
</form>
Punto 2 ="($_SESSION['MM_id_user'])) {" tu pones el nombre de tu sesion.
espero se entienda...
saludos