Tema: Problema php
Ver Mensaje Individual
  #5 (permalink)  
Antiguo 05/11/2013, 17:33
Avatar de Maverick2786
Maverick2786
 
Fecha de Ingreso: diciembre-2012
Mensajes: 107
Antigüedad: 11 años, 4 meses
Puntos: 1
Respuesta: Problema php

Gracias tambien por avisame lo de la fecha, ya esta todo bien, pongo el codigo:
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.         <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  6.         <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  7.         <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  8.         <link rel="stylesheet" href="/resources/demos/style.css" />
  9.        
  10.          <script>
  11.             $(function() {
  12.                 $( "#datepicker1" ).datepicker({ dateFormat: 'dd/mm/yy' });
  13.                 $( "#datepicker2" ).datepicker({ dateFormat: 'dd/mm/yy' });
  14.             });
  15.         </script>
  16.     <title>Documento sin título</title>
  17.     </head>
  18.    
  19.     <body>
  20.         <form action="ingresar.php" method="post">
  21.             Escribe tu id: <input type="text" name="id" size="2">
  22.             Escribe tu nombre: <input type="text" name="nombre" size="10">
  23.             <p>fecha1: <input type="text" id="datepicker1"  name="fecha1"/></p>
  24.             <p>fecha2: <input type="text" id="datepicker2"  name="fecha2"/></p>
  25.             <input type="submit" value="Entrar">
  26.         </form>
  27.     </body>
  28. </html>

en php:
Código PHP:
Ver original
  1. <?php
  2.     $conexion = mysql_connect("localhost","root","");
  3.     mysql_select_db("prueba",$conexion);
  4.  
  5.     $id=$_POST["id"];
  6.     $nombre=$_POST["nombre"];
  7.     $fecha1 = date("Y-m-d",strtotime($_POST["fecha1"]));
  8.     $fecha2 = date("Y-m-d",strtotime($_POST["fecha2"]));
  9.    
  10.     $sql="INSERT INTO tablaPrueba (id,nombre,fecha1,fecha2) VALUES ($id,'$nombre','$fecha1','$fecha2')";
  11.     mysql_query($sql);
  12. ?>