Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] php Notice: Undefined index:

Estas en el tema de php Notice: Undefined index: en el foro de PHP en Foros del Web. Hola a todos tengo este problema que no se como resolver ya busque en varias paginas y no logro resolver el problema. Espero me puedan ...
  #1 (permalink)  
Antiguo 08/09/2014, 09:32
 
Fecha de Ingreso: septiembre-2014
Ubicación: Mexico df
Mensajes: 5
Antigüedad: 9 años, 7 meses
Puntos: 0
Pregunta php Notice: Undefined index:

Hola a todos tengo este problema que no se como resolver ya busque en varias paginas y no logro resolver el problema.

Espero me puedan ayudar. GRACIAS

TENGO ESTE CODIGO Y ME MARCA ERROR EN LA LINEA 32 NO SE A QUE SE DEBE.

Notice: Undefined index: fechainicio in C:\wamp\www\GEN\paginas\FrmAltasCortes.php on line 32

<h1 class="txtcenter">Cortes</h1>
<div id="wrapper-altas" class="w550p mod">
<div id="steps">
<form id="FrmAltasCortes" name="FrmAltasCortes" action='#' method="post">
<fieldset class="step">
<legend>Ingresar Cortes</legend>
<div class="float txtcenter center">
<p style="width: 185px">
<label style="text-align: left; margin-left: 10px" for="fechainicio">Fecha Inicial</label>
<input name="fechainicio" type="text" id="fechainicio" size="10" onblur="isDate(this);"/><br/>
<input type="button" value="..." onclick="displayCalendar(document.FrmAltasCortes.f echainicio,'dd/mm/yyyy',this);"/>
</p>
</div>
<div class="float txtcenter center">
<p style="width: 185px">
<label style="text-align: left; margin-left: 10px" for="fechafin">Fecha Final</label> <br/>
<input name="fechafin" type="text" id="fechafin" size="10" onblur="isDate(this);"/>
<input type="button" value="..." onclick="displayCalendar(document.FrmAltasCortes.f echafin,'dd/mm/yyyy',this);"/>
</p>

</div>
<p class="submit">
<button onclick="return validafechamayor2('#fechainicio', '#fechafin');" id="registerButton" type="submit">Consultar</button>
</p>
</fieldset>
</form>
<section id="res">
<?php
try{
include 'Validaciones.php';
if ($_POST['fechainicio'] and $_POST['fechafin']) {
$fechainicio=fechaymd($_POST['fechainicio']);
$fechafin=fechaymd($_POST['fechafin']);
$gastos=0;
$pagos=0;
$total=0;

include ('db_mysql.inc');

$mysqli = Conectarse();
$sqlgasto="SELECT SUM(total) FROM detalle_gastos WHERE (SELECT MAX(id) FROM detalle_gastos)
AND fecha BETWEEN '".$fechainicio."' and '".$fechafin."';";


$sqlpagos="SELECT SUM(abono) FROM pagos WHERE (SELECT MAX(id) FROM pagos) AND fecha
BETWEEN '".$fechainicio."' and '".$fechafin."';";



if ($rs = $mysqli->query($sqlpagos)) {
while($fila = $rs->fetch_assoc()) {
$pagos=$fila ["SUM(abono)"];
}
?>
<form id="formElem" name="ResCortes" action='ProcesoGuardaCorte.php' method="post">
<p>
<label for="ingresos">Total Ingresos $</label>
<input id="ingresos" type="text" name="ingresos" value="<?php echo $pagos?>" size="5" readonly="readonly"/>
</p>
<?php
}
if ($rs = $mysqli->query($sqlgasto)) {
while($fila = $rs->fetch_assoc()) {
$gastos=$fila ["SUM(total)"];
}
?>
<p>
<label for="gastos">Total Gastos $</label>
<input id="gastos" type="text" name="gastos" value="<?php echo $gastos?>" size="5" readonly="readonly"/>
</p>

<?php
}
$total=$pagos-$gastos;
?>
<p>
<label for="corte">Total Corte $</label>
<input id="corte" type="text" name="corte" value="<?php echo $total?>" size="5" readonly="readonly"/>
</p>
<input id="fechainicio1" type="hidden" name="fechainicio" value="<?php echo $fechainicio; ?>"/>
<input id="fechafin1" type="hidden" name="fechafin" value="<?php echo $fechafin; ?>"/>

<p class="submit">
<button id="registerButton" onclick="return validafechamayor();" type="button">Ingresar Corte</button>
</p>
</form>
<?php
}else{ }
}catch(Exception $e){}
?>

</section>
</div>
<div id="navigation" style="display:none;">
<ul>
<li class="selected">
<a href="#">Cortes</a>
</li>

</ul>
</div>
</div>
  #2 (permalink)  
Antiguo 08/09/2014, 09:47
Avatar de CHuLoSoY  
Fecha de Ingreso: febrero-2002
Ubicación: Ribeira (Galicia)
Mensajes: 1.900
Antigüedad: 22 años, 2 meses
Puntos: 29
Respuesta: php Notice: Undefined index:

Código PHP:
Ver original
  1. if ( !empty($_POST['fechainicio']) && !empty($_POST['fechafin'])) {

Con eso , solucionado el error que tienes, pero me da que tendrás muchos más problemas.

Saludos.
__________________
ESQUIO Dominios y Hosting
Las mejores características con los mejores precios.
  #3 (permalink)  
Antiguo 08/09/2014, 10:14
 
Fecha de Ingreso: septiembre-2014
Ubicación: Mexico df
Mensajes: 5
Antigüedad: 9 años, 7 meses
Puntos: 0
De acuerdo Respuesta: php Notice: Undefined index:

GRACIAS CHuLoSoY.


Ya escribí tal como lo escribiste el código y si se corrigió el error

de antemano muchas gracias por darme una solución.
  #4 (permalink)  
Antiguo 08/09/2014, 13:33
 
Fecha de Ingreso: septiembre-2014
Ubicación: Mexico df
Mensajes: 5
Antigüedad: 9 años, 7 meses
Puntos: 0
Respuesta: php Notice: Undefined index:

Cita:
Iniciado por miguelgarciameneses Ver Mensaje
GRACIAS CHuLoSoY.


Ya escribí tal como lo escribiste el código y si se corrigió el error

de antemano muchas gracias por darme una solución.

Etiquetas: fecha, mysql, notice, select, sql, undefined
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:34.