File: /home/ednermusika/ednergranados.com/admin/galeriaaudios_altas.php
<?php require_once('../Connections/con_edner.php'); ?>
<?php require_once('../Connections/con_edner.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO galeria_audio (gaa_consecutivo, usu_consecutivo, gaa_titulo, gaa_fecha, gaa_ruta, gaa_activo) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['gaa_consecutivo'], "int"),
GetSQLValueString($_POST['usu_consecutivo'], "int"),
GetSQLValueString($_POST['gaa_titulo'], "text"),
GetSQLValueString($_POST['gaa_fecha'], "date"),
GetSQLValueString($_POST['gaa_ruta'], "text"),
GetSQLValueString($_POST['gaa_activo'], "int"));
mysql_select_db($database_con_edner, $con_edner);
$Result1 = mysql_query($insertSQL, $con_edner) or die(mysql_error());
$insertGoTo = "galeriaaudios_admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_con_edner, $con_edner);
$query_MAXIMO = "SELECT IFNULL(MAX(gaa_consecutivo),0)+1 as MAXIMO, CURDATE() as FECHA_HOY FROM galeria_audio ";
$MAXIMO = mysql_query($query_MAXIMO, $con_edner) or die(mysql_error());
$row_MAXIMO = mysql_fetch_assoc($MAXIMO);
$totalRows_MAXIMO = mysql_num_rows($MAXIMO);
?>
<!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=iso-8859-1" />
<title>Untitled Document</title>
<link href="css/admin.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h1>Galería de Audios</h1></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><a href="galeriaaudios_admin.php" class="ligas_menu_interiores">« Regresar</a></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td><hr class="hr_principal" /></td>
</tr>
</table>
<form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1">
<table>
<tr valign="baseline">
<td colspan="2" nowrap="nowrap"><h3>Nueva galería de audios</h3></td>
</tr>
<tr valign="baseline">
<td width="159" nowrap="nowrap" class="texto_14_verdana"> </td>
<td width="379"><input name="gaa_consecutivo" type="hidden" id="gaa_consecutivo" value="<?php echo $row_MAXIMO['MAXIMO']; ?>" size="32" />
<input type="hidden" name="usu_consecutivo" value="<?php echo $_SESSION['USUARIO'] ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap"><h4>Título:</h4></td>
<td><input name="gaa_titulo" type="text" id="gaa_titulo" value="" size="50" maxlength="50" />
<span class="texto_14_verdana">
<input name="gaa_fecha" type="hidden" id="gaa_fecha" value="<?php echo $row_MAXIMO['FECHA_HOY']; ?>" size="32" />
</span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" class="texto_14_verdana"> </td>
<td> </td>
</tr>
<tr valign="baseline">
<td height="24" nowrap="nowrap" class="texto_14_verdana">
<input name="gaa_ruta" type="hidden" id="gaa_ruta" value="galeria-audios/" size="32" />
<input name="gaa_activo" type="hidden" id="gaa_activo" value="1" size="32" /></td>
<td><input name="guardar" type="button" id="guardar" value="Guardar" onclick="f_enviar();"/>
<input type="reset" name="limpiar" id="limpiar" value="Limpiar" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
<script type="text/javascript">
function f_validar ( )
{
var retorno = true;
with ( document.form1 )
{
if ( gaa_titulo.value == '' )
{
alert ( 'Por favor proporcione el t�tulo de la galer�a' );
gaa_titulo.focus ( );
retorno = false;
}
return retorno
}
}
function f_enviar()
{
with (document.form1)
{
if ( f_validar ( ) )
{
submit ( );
}
}
}
</script>
</html>
<?php
mysql_free_result($MAXIMO);
?>