Ver Mensaje Individual
  #8 (permalink)  
Antiguo 02/08/2012, 03:53
mcg_4
 
Fecha de Ingreso: marzo-2012
Mensajes: 24
Antigüedad: 12 años, 1 mes
Puntos: 0
Respuesta: guardar formulario en bbdd

Vaya..era eso..Muchas gracias Eleazan!!
Ahora ya no me da errores, pero al ejecutarlo no se ha guardado. Además, la intención es que al dar a guardar se vuelva a cargar la misma página, con los nuevos valores.
En cambio en mi caso al dar a guardar ha aparecido la página en blanco.
Vuelvo a pegar el código:

Código HTML:
Ver original
  1. <div class="contenedor_contenidos">
  2.         <?php
  3.             //crea conexión con la bbdd
  4.             $conexion=mysql_connect("localhost","root","") or die("Problemas en la conexion");
  5.             mysql_select_db("clientes",$conexion) or die("Problemas en la seleccion de la base de datos");
  6.         if($_REQUEST['codigo']=="-")
  7.         {
  8.             //si no hemos definido el código, creamos cliente nuevo
  9.             //insertamos los parámetros del nuevo cliente en la tabla
  10.             mysql_query("insert into clientes(nombre,cif,direccion,codigo_postal,ciudad,telefono,fax,email,fecha_alta) values
  11.   (".$_REQUEST['nombre'].",".$_REQUEST['cif'].",".$_REQUEST['direccion'].",".$_REQUEST['cp'].",".$_REQUEST['ciudad'].",".$_REQUEST['telefono'].",".$_REQUEST['fax'].",".$_REQUEST['email'].",date(d/m/y))",
  12.   $conexion) or die("Problemas en el select".mysql_error());
  13.     mysql_close($conexion);
  14.     echo "El cliente ha sido añadido.";
  15.         }
  16.         else
  17.         {
  18.             //si definimos el código, modificamos cliente existente
  19.             //seleccionamos el cliente con el codigo correspondiente
  20.             //$registros=mysql_query("select * from clientes where id=".$_REQUEST['codigo']."",$conexion) or die("Problemas en el select:".mysql_error());
  21.             if ($reg=mysql_fetch_array($registros))
  22.             {
  23.                 //modificamos los diferentes campos de la tabla...como se haría el update??
  24.                 //$registros=mysql_query("update clientes set cif=".$_REQUEST[mailnuevo]." where nombre=".$_REQUEST[nombre]."",$conexion) or  die("Problemas en el select:".mysql_error());
  25.                 echo "El mail fue modificado con exito";
  26.             }
  27.         }
  28.             ?>
  29.            
  30.           <div class="contenidos">
  31.           <br/><br/><br/>
  32.           <!--formulario para introducir los datos del cliente-->
  33.           <form style="margin-left:200px;" method="post" action="guardar-cliente.php">
  34.                 Código: <input type="text" name="codigo" size="20" value="-"> <span style="margin-left:190px;" >Núm. albaranes: <input type="text" name="num_albaranes" size="20" value="0"/></span>
  35.  
  36.                 <br/><br/><br/>
  37.                 <button type="submit">Nombre: </button>  <input type="text" name="nombre" size="60"> <span style=" margin-left:10px;" >CIF: <input type="text" name="cif" size="20" /></span>
  38.                 <br/><br/><br/>
  39.                 Dirección: <input type="text" name="direccion" size="50" /><br/><br/>
  40.                 C.P.: <input type="text" name="cp" size="10" /> <span style="margin-left:10px;">Ciudad: <input type="text" name="ciudad" size="30" /></span>
  41.                 <br/><br/><br/>
  42.                 Teléfono: <input type="text" name="telefono" size="20" /> <span style="margin-left:20px;">Fax: <input type="text" name="fax" size="20" /></span><br/><br/>
  43.                 E-mail: <input type="text" name="email" size="55" />
  44.                 <br/><br/>                <span style="margin-left:420px;">Fecha de alta: <input type="text" name="fecha_alta"  value="dd/mm/aa"/></span><br/><br/>
  45.  
  46.                
  47.             <span style="margin-left:280px;"><button type="submit"><br/>Guardar<br/><br/></button>
  48.             <button type="reset"><br/>  Borrar <br/><br/></button></span>
  49.                            
  50.             </form></div>