Código 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"] == "form1")) {
$updateSQL = sprintf("UPDATE noticias SET created=%s, noticia_titulo=%s, texto=%s WHERE id_noticias=%s",
GetSQLValueString($_POST['created'], "date"),
GetSQLValueString($_POST['noticia_titulo'], "text"),
GetSQLValueString($_POST['texto'], "text"),
GetSQLValueString($_POST['id_noticias'], "int"));
mysql_select_db($database_promautos, $promautos);
$Result1 = mysql_query($updateSQL, $promautos) or die(mysql_error());
$updateGoTo = "actualizado.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_noticias = "-1";
if (isset($_GET['id_noticias'])) {
$colname_noticias = (get_magic_quotes_gpc()) ? $_GET['id_noticias'] : addslashes($_GET['id_noticias']);
}
mysql_select_db($database_promautos, $promautos);
$query_noticias = sprintf("SELECT * FROM noticias WHERE id_noticias = %s", $colname_noticias);
$noticias = mysql_query($query_noticias, $promautos) or die(mysql_error());
$row_noticias = mysql_fetch_assoc($noticias);
$totalRows_noticias = mysql_num_rows($noticias);
?>
Ese es el codigo completo, sin los html