Código:
Ese es el archivo consulta.php, el cual muestra la informacion y hasta ahi todo bien pero al editar con el archivo de abajo me da problemas.<?php require('clases/cliente.class.php'); $objCliente=new Cliente; $consulta=$objCliente->mostrar_clientes(); ?> <script type="text/javascript"> $(document).ready(function(){ // mostrar formulario de actualizar datos $("table tr .modi a").click(function(){ $('#tabla').hide(); $("#formulario").show(); $.ajax({ url: this.href, type: "GET", success: function(datos){ $("#formulario").html(datos); } }); return false; }); // llamar a formulario nuevo $("#nuevo a").click(function(){ $("#formulario").show(); $("#tabla").hide(); $.ajax({ type: "GET", url: 'nuevo.php', success: function(datos){ $("#formulario").html(datos); } }); return false; }); }); </script> <span id="nuevo"><a href="nuevo.php"><img src="img/add.png" alt="Agregar dato" /></a></span> <table> <tr> <th>Nombres</th> <th>Cantidad</th> <th>Ciudad</th> <th>Sexo</th> <th>Telefono</th> <th>Fecha Nacimiento</th> <th></th> <th></th> </tr> <?php if($consulta) { while( $cliente = mysql_fetch_array($consulta) ){ ?> <tr id="fila-<?php echo $cliente['id'] ?>"> <td><?php echo $cliente['nombres'] ?></td> <td><?php echo $cliente['cantidad'] ?></td> <td><?php echo $cliente['ciudad'] ?></td> <td><?php echo $cliente['sexo'] ?></td> <td><?php echo $cliente['telefono'] ?></td> <td><?php echo $cliente['fecha_nacimiento'] ?></td> <td><span class="modi"><a href="actualizar.php?id=<?php echo $cliente['id'] ?>"><img src="img/database_edit.png" title="Editar" alt="Editar" /></a></span></td> <td><span class="dele"><a onClick="EliminarDato(<?php echo $cliente['id'] ?>); return false" href="eliminar.php?id=<?php echo $cliente['id'] ?>"><img src="img/delete.png" title="Eliminar" alt="Eliminar" /></a></span></td> </tr> <?php } } ?> </table>
Código:
Este es el archivo actualizar.php y es el que me da los problemas, lo que agregue es el $cantidad = htmlspecialchars(trim($_POST['cantidad'])); , el error que me da es el :<?php require('functions.php'); if(isset($_POST['submit'])){ require('clases/cliente.class.php'); $objCliente=new Cliente; $cliente_id = htmlspecialchars(trim($_POST['cliente_id'])); $nombres = htmlspecialchars(trim($_POST['nombres'])); $cantidad = htmlspecialchars(trim($_POST['cantidad'])); $ciudad = htmlspecialchars(trim($_POST['ciudad'])); $sexo = htmlspecialchars(trim($_POST['alternativas'])); $telefono = htmlspecialchars(trim($_POST['telefono'])); $fecha_nacimiento = htmlspecialchars(trim($_POST['fecha_nacimiento'])); if ( $objCliente->actualizar(array($nombres,$cantidad,$ciudad,$sexo,$telefono,$fecha_nacimiento),$cliente_id) == true){ echo 'Datos guardados'; }else{ echo 'Se produjo un error. Intente nuevamente'; } }else{ if(isset($_GET['id'])){ require('clases/cliente.class.php'); $objCliente=new Cliente; $consulta = $objCliente->mostrar_cliente($_GET['id']); $cliente = mysql_fetch_array($consulta); ?> <form id="frmClienteActualizar" name="frmClienteActualizar" method="post" action="actualizar.php" onsubmit="ActualizarDatos(); return false"> <input type="hidden" name="cliente_id" id="cliente_id" value="<?php echo $cliente['id']?>" /> <p> <label>Nombres<br /> <input class="text" type="text" name="nombres" id="nombres" value="<?php echo $cliente['nombres']?>" /> </label> </p> <p> <label>Cantidad<br /> <input class="text" type="text" name="cantidad" id="cantidad" value="<?php echo $cliente['cantidad']?>" /> </label> </p> <p> <label>Ciudad<br /> <input class="text" type="text" name="ciudad" id="ciudad" value="<?php echo $cliente['ciudad']?>" /> </label> </p> <p> <label> <input type="radio" name="alternativas" id="masculino" value="M" <?php if($cliente['sexo']=="M") echo "checked=\"checked\""?> /> Masculino</label> <label> <input type="radio" name="alternativas" id="femenino" value="F" <?php if($cliente['sexo']=="F") echo "checked=\"checked\""?> /> Femenino</label> </p> <p> <label>Telefono<br /> <input class="text" type="text" name="telefono" id="telefono" value="<?php echo $cliente['telefono']?>" /> </label> </p> <p> <label>Fecha Nacimiento <a onclick="show_calendar()" style="cursor: pointer;"><small>(calendario)</small></a><br /> <input readonly="readonly" class="text" type="text" name="fecha_nacimiento" id="fecha_nacimiento" value="<?php echo $cliente['fecha_nacimiento'] ?>" /> <div id="calendario" style="display:none;"><?php calendar_html() ?></div> </label> </p> <p> <input type="submit" name="submit" id="button" value="Enviar" /> <label></label> <input type="button" name="cancelar" id="cancelar" value="Cancelar" onclick="Cancelar()" /> </p> </form> <?php } } ?>
Notice: Undefined index: cantidad
Código:
y no guarda.<br /> <font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'> <tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: cantidad in C:\wamp\www\Editable Jquery\actualizar.php on line <i>9</i></th></tr> <tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr> <tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function</th><th align='left' bgcolor='#eeeeec'>Location</th></tr> <tr><td bgcolor='#eeeeec' align='center'>1</td><td bgcolor='#eeeeec' align='center'>0.0007</td><td bgcolor='#eeeeec' align='right'>389272</td><td bgcolor='#eeeeec'>{main}( )</td><td title='C:\wamp\www\Editable Jquery\actualizar.php' bgcolor='#eeeeec'>..\actualizar.php<b>:</b>0</td></tr> </table></font> Datos guardados
Alguien me puede ayudar por favor. Desde ya muchas gracias.