File: /home/ednermusika/ednergranados.com/admin/Nueva carpeta/clientes_altas.php
<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
?>
<?php require_once('../Connections/con_edner.php'); ?>
<?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 clientes (cli_consecutivo, usu_consecutivo, cli_nombre, cli_rutalogo, cli_fecha, cli_activo) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['cli_consecutivo'], "int"),
GetSQLValueString($_POST['usu_consecutivo'], "int"),
GetSQLValueString($_POST['cli_nombre'], "text"),
GetSQLValueString($_POST['cli_rutalogo'], "text"),
GetSQLValueString($_POST['cli_fecha'], "date"),
GetSQLValueString($_POST['cli_activo'], "int"));
mysql_select_db($database_con_edner, $con_edner);
$Result1 = mysql_query($insertSQL, $con_edner) or die(mysql_error());
$insertGoTo = "clientes_admin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
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;
}
}
mysql_select_db($database_con_edner, $con_edner);
$query_MAXIMO = "SELECT IFNULL(MAX(cli_consecutivo),0)+1 as MAXIMO, CURDATE() as FECHA_HOY FROM clientes";
$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>clier�a (Altas)</title>
<link href="css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h1>Clientes</h1></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td><a href="clientes_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>
<blockquote>
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<table width="502">
<tr valign="baseline">
<td colspan="2" nowrap="nowrap"><h3>Nuevo Cliente</h3></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h4> </h4></td>
<td><input name="cli_consecutivo" type="hidden" id="cli_consecutivo" value="<?php echo $row_MAXIMO['MAXIMO']; ?>" size="32" />
<input type="hidden" name="usu_consecutivo" value="<?php echo $_SESSION['USUARIO'] ?>" size="32" />
<input name="cli_fecha" type="hidden" id="cli_fecha" value="<?php echo $row_MAXIMO['FECHA_HOY']; ?>" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h4>Nombre:</h4></td>
<td><input name="cli_nombre" type="text" id="cli_nombre" size="50" maxlength="50" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h4>Logo:</h4></td>
<td><input name="cli_rutalogo" type="file" id="cli_rutalogo" size="35" />
<input name="cli_activo" type="hidden" id="cli_activo" value="1" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"><h4> </h4></td>
<td><input name="guardar" type="button" class="boton_panel" id="guardar" onclick="MM_callJS('f_enviar();')" value="Guardar" />
<input name="limpiar" type="reset" class="boton_panel" id="limpiar" value="Limpiar" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</blockquote>
</body>
</html>
<script type="text/javascript">
function f_validar ( )
{
var retorno = true;
with ( document.form1 )
{
if ( cli_nombre.value == '' )
{
alert ( 'Por favor proporcione el t�tulo' );
cli_nombre.focus ( );
retorno = false;
}
return retorno
}
}
function f_enviar()
{
with (document.form1)
{
if ( f_validar ( ) )
{
submit ( );
}
}
}
</script>
<?php
mysql_free_result($MAXIMO);
?>