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);
?>