Ver Mensaje Individual
  #7 (permalink)  
Antiguo 30/12/2014, 10:55
Mental
 
Fecha de Ingreso: noviembre-2005
Mensajes: 146
Antigüedad: 18 años, 5 meses
Puntos: 1
Respuesta: boton submit y evento

Cita:
<body>
<h1> Formulario de registro </h1>
<?php

$var0=""; //Id del presupuesto
$var1=""; // Fecha presupuesto
$var2=""; // Número de presupuesto
$var3=""; // Apellidos cliente
$var4=""; // Nº de usuarios
$var5=""; // Inicio del evento
$var6=""; // Fin del evento
$var7=""; // Días de duración
$var8=""; // Horas de duración
$var9=""; // Confirmación del depósito
$var10=""; // Fecha confirmación
$var11=""; // Depósito entregado
$var12=0.0; // Presupuesto
$var13=0.0; // Coste servicios
$var14=0.0; // Resultado
$var15=""; // Fecha de la factura
$var16=""; // Nº factura
$var17=""; // Servicios a coordinar
$var18="Este es el texto por defecto"; // Observaciones

$sql="SELECT count(Id_Presupuesto) as totreg FROM presupuestos";
$cs=mysql_query($sql,$cn);

while($resul=mysql_fetch_array($cs))
{
$totreg=$resul[0];
$cont=$totreg;
}

$sql="SELECT * FROM presupuestos";
$cs=mysql_query($sql,$cn);

while($resul=mysql_fetch_array($cs))

{

$var0=$resul[0];
$mifecha= date_create($resul[1]);
$var1=date_format($mifecha,'d/m/Y');
$var2=$resul[2];

$var3=$resul[3];
$misql="SELECT * FROM clientes WHERE id_Clientes = $var3";
$ca=mysql_query($misql,$cn);
while($resul_a=mysql_fetch_array($ca))
{
$var3=$resul_a['1'];
}
$var4=$resul[4];
$mifecha= date_create($resul[5]);
$var5=date_format($mifecha,'d/m/Y');
$mifecha= date_create($resul[6]);
$var6=date_format($mifecha,'d/m/Y');
$var7=$resul[7];
$var8=$resul[8];
$var9=$resul[9];
$mifecha= date_create($resul[10]);
$var10=date_format($mifecha,'d/m/Y');
$var11=$resul[11];
$var12=$resul[12];
$var13=$resul[13];
$var14=$resul[14];
$mifecha= date_create($resul[15]);
$var15=date_format($mifecha,'d/m/Y');
$var16=$resul[16];
$mifecha='';
}

if(isset($_POST["btn1"]))
{
$btn=$_POST["btn1"];
$bus=$_POST["txtbus"];
if($btn=="Buscar")
{

$sql="SELECT *FROM Presupuestos where Id_Presupuesto='$bus'";
$cs=mysql_query($sql,$cn);
while($resul=mysql_fetch_array($cs))
{
$var0=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];
$var4=$resul[4];
$var5=$resul[5];
$var6=$resul[6];
$var7=$resul[7];
$var8=$resul[8];
$var9=$resul[9];
$var10=$resul[10];
$var11=$resul[11];
$var12=$resul[12];
$var13=$resul[13];
$var14=$resul[14];
$var15=$resul[15];
}
}

//================================================== =================
//INICIO DE METODOS DEDICADOS A LA PAGINACIÓN DEL FORUMULARIO

if($btn=="Primero")
{
$cont=1;
$max_reg=$cont;
include("seleccionar_bd.php");
}

if($btn=="Anterior")
{
$cont=$_POST["txtvariable"];
if($_POST["txtvariable"] >1 )
{
$cont=$cont-1;
$max_reg=$cont;
include("seleccionar_bd.php");
}
elseif ($_POST["txtvariable"] =1)
{
$cont=1;
$max_reg=$cont;
include("seleccionar_bd.php");
}
}
if($btn=="Siguiente")
{
$cont=$_POST["txtvariable"];
if($_POST["txtvariable"]!==0 and $_POST["txtvariable"] < $totreg)
{
$cont=$cont+1;
$max_reg=$cont;
include("seleccionar_bd.php");
}
}
if($btn=="Ultimo")
{
$cont=$totreg;
$max_reg=$cont;
include("seleccionar_bd.php");
}

//FINAL DE METODOS DEDICADOS A LA PAGINACIÓN DEL FORUMULARIO
//================================================== ====================

if($btn=="Nuevo")
{
$cn=mysql_close($cn);
$var0=""; //Id del presupuesto
$var1=""; // Fecha presupuesto
$var2=""; // Número de presupuesto
$var3=""; // Apellidos cliente
$var4=""; // Nº de usuarios
$var5=""; // Inicio del evento
$var6=""; // Fin del evento
$var7=""; // Días de duración
$var8=""; // Horas de duración
$var9=""; // Confirmación del depósito
$var10=""; // Fecha confirmación
$var11=""; // Depósito entregado
$var12=0.0; // Presupuesto
$var13=0.0; // Coste servicios
$var14=0.0; // Resultado
$var15=""; // Fecha de la factura
$var16=""; // Nº factura
$var17=""; // Servicios a coordinar
$var18="Este es el texto por defecto"; // Observaciones<script type="txt/javascript">

}
if($btn=="Agregar")
{
$fpr=$_POST["txtfpr"];
$pre=$_POST["txtpre"];
$ape=$_POST["txtape"];
$usu=$_POST["txtusu"];
$ini=$_POST["txtini"];
$fin=$_POST["txtfin"];
$dep=$_POST["txtdep"];
$fde=$_POST["txtfde"];
$idp=$_POST["txtidp"];
$ser=$_POST["txtser"];
$vpr=$_POST["txtvpr"];
$cos=$_POST["txtcos"];
$res=$_POST["txtres"];
$fac=$_POST["txtfac"];
$ffa=$_POST["txtffa"];
$obs=$_POST["txtobs"];


$sql="INSERT into presupuestos values ('$fpr','$pre','$ape','$usu','$ini','$fin','$dep', '$fde','$idp','$ser','$vpr','$cos','$res','$fac',' $ffa','$obs')";
$cs=mysql_query($sql,$cn);
echo "<script> alert('Se insert&oacute; correctamente');</script>";
}

if($btn=="Actualizar")
{
$fpr=$_POST["txtfpr"];
$pre=$_POST["txtpre"];
$ape=$_POST["txtape"];
$usu=$_POST["txtusu"];
$ini=$_POST["txtini"];
$fin=$_POST["txtfin"];
$dep=$_POST["txtdep"];
$fde=$_POST["txtfde"];
$idp=$_POST["txtidp"];
$ser=$_POST["txtser"];
$vpr=$_POST["txtvpr"];
$cos=$_POST["txtcos"];
$res=$_POST["txtres"];
$fac=$_POST["txtfac"];
$ffa=$_POST["txtffa"];
$obs=$_POST["txtobs"];

$sql="UPDATE presupuestos set fecha_presupuesto='$fpr',Ref_Pres='$pre',Id_Client e='$ape',Usuarios='$usu', Fecha_Inicio ='$ini',
fecha_fin ='$fin',


where Ref_Pres='$pre'";

$cs=mysql_query($sql,$cn);
echo "<script> alert('Se actualizo correctamente');</script>";
}
}

?>