Foros del Web » Programando para Internet » PHP »

PHP OO agregar calendario en mi registro

Estas en el tema de agregar calendario en mi registro en el foro de PHP en Foros del Web. Cordiales saludos amigos ; en esta oportunidad vengo a exponerles mi problema y quisiera que me ayuden. Estoy haciendo un registro entonces , contiene los ...
  #1 (permalink)  
Antiguo 13/06/2013, 20:58
Avatar de nexus44  
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
Exclamación agregar calendario en mi registro

Cordiales saludos amigos ; en esta oportunidad vengo a exponerles mi problema y quisiera que me ayuden.

Estoy haciendo un registro entonces , contiene los siguientes campos :

Usuario
Nombre
Apellido
contraeña
E-mail
Fecha .

todo esta perfecto , lo que yo quisiera es que me ayuden como poner un calendario en la fecha sin tener que estar escribiendo no? o de alguna manera como autogenerar la fecha del momento que se esta registrando aqui dejo mi codigo.

GRACIAS.

Código PHP:
Ver original
  1. <?php require_once('Connections/con_usuarios.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. // *** Redirect if username exists
  35. $MM_flag="MM_insert";
  36. if (isset($_POST[$MM_flag])) {
  37.   $MM_dupKeyRedirect="ya_existe.php";
  38.   $loginUsername = $_POST['nombre_user'];
  39.   $LoginRS__query = sprintf("SELECT nombre_user FROM usuarios WHERE nombre_user=%s", GetSQLValueString($loginUsername, "text"));
  40.   mysql_select_db($database_con_usuarios, $con_usuarios);
  41.   $LoginRS=mysql_query($LoginRS__query, $con_usuarios) or die(mysql_error());
  42.   $loginFoundUser = mysql_num_rows($LoginRS);
  43.  
  44.   //if there is a row in the database, the username was found - can not add the requested username
  45.   if($loginFoundUser){
  46.     $MM_qsChar = "?";
  47.     //append the username to the redirect page
  48.     if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
  49.     $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
  50.     header ("Location: $MM_dupKeyRedirect");
  51.     exit;
  52.   }
  53. }
  54.  
  55. $editFormAction = $_SERVER['PHP_SELF'];
  56. if (isset($_SERVER['QUERY_STRING'])) {
  57.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  58. }
  59.  
  60. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  61.   $insertSQL = sprintf("INSERT INTO usuarios (nombre_user, nombre, apellido, password, email, fecha) VALUES (%s, %s, %s, %s, %s, %s)",
  62.                        GetSQLValueString($_POST['nombre_user'], "text"),
  63.                        GetSQLValueString($_POST['nombre'], "text"),
  64.                        GetSQLValueString($_POST['apellido'], "text"),
  65.                        GetSQLValueString($_POST['password'], "text"),
  66.                        GetSQLValueString($_POST['email'], "text"),
  67.                        GetSQLValueString($_POST['fecha'], "text"));
  68.  
  69.   mysql_select_db($database_con_usuarios, $con_usuarios);
  70.   $Result1 = mysql_query($insertSQL, $con_usuarios) or die(mysql_error());
  71.  
  72.   $insertGoTo = "index.php";
  73.   if (isset($_SERVER['QUERY_STRING'])) {
  74.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  75.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  76.   }
  77.   header(sprintf("Location: %s", $insertGoTo));
  78. }
  79. ?>
  80.  
  81. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  82. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/base.dwt.php" codeOutsideHTMLIsLocked="false" -->
  83. <head>
  84. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  85. <!-- InstanceBeginEditable name="doctitle" -->
  86. <title>.:Registro de usuarios::.</title>
  87. <!-- InstanceEndEditable -->
  88. <style type="text/css">
  89. <!--
  90. body {
  91.     margin-top: 0px;
  92.     background-image: url(fondo.jpg);
  93.     background-repeat: repeat-x;
  94. }
  95. -->
  96. </style>
  97. <!-- InstanceBeginEditable name="head" -->
  98. <script type="text/javascript">
  99. <!--
  100. function MM_validateForm() { //v4.0
  101.   if (document.getElementById){
  102.     var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  103.     for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
  104.       if (val) { nm=val.name; if ((val=val.value)!="") {
  105.         if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
  106.           if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
  107.         } else if (test!='R') { num = parseFloat(val);
  108.           if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
  109.           if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
  110.             min=test.substring(8,p); max=test.substring(p+1);
  111.             if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
  112.       } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  113.     } if (errors) alert('The following error(s) occurred:\n'+errors);
  114.     document.MM_returnValue = (errors == '');
  115. } }
  116. //-->
  117. </script>
  118. <script>
  119.     function soloLetras(e){
  120.        key = e.keyCode || e.which;
  121.        tecla = String.fromCharCode(key).toLowerCase();
  122.        letras = " áéíóúabcdefghijklmnñopqrstuvwxyz";
  123.        especiales = [8,37,39,46];
  124.  
  125.        tecla_especial = false
  126.        for(var i in especiales){
  127.             if(key == especiales[i]){
  128.                 tecla_especial = true;
  129.                 break;
  130.             }
  131.         }
  132.  
  133.         if(letras.indexOf(tecla)==-1 && !tecla_especial){
  134.             return false;
  135.         }
  136.     }
  137. </script>
  138.  
  139. <!-- InstanceEndEditable -->
  140. </head>
  141.  
  142. <body>
  143. <table width="80%" border="0" align="center">
  144.  
  145.   <tr>
  146.     <td align="center" bgcolor="#129ae8"><!-- InstanceBeginEditable name="contenido" -->
  147.  
  148.       <h2><img src="imagenes/rgus.jpg" width="500" height="100" /></h2>
  149.       <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  150.         <table align="center" onfocus="MM_validateForm('nombre_user','','R','nombre','','R','apellido','','R','password','','R','email','','RisEmail','fecha','','R');return document.MM_returnValue">
  151.           <tr valign="baseline">
  152.             <td nowrap="nowrap" align="right"><strong>Usuario:</strong></td>
  153.             <td><input name="nombre_user" onkeypress="return soloLetras(event)" type="text" id="nombre_user" value="" size="32" /></td>
  154.           </tr>
  155.           <tr valign="baseline">
  156.             <td nowrap="nowrap" align="right"><strong>Nombre:</strong></td>
  157.             <td><input name="nombre" onkeypress="return soloLetras(event)" type="text" id="nombre" value="" size="32" /></td>
  158.           </tr>
  159.           <tr valign="baseline">
  160.             <td nowrap="nowrap" align="right"><strong>Apellido:</strong></td>
  161.             <td><input name="apellido" onkeypress="return soloLetras(event)" type="text" id="apellido" value="" size="32" /></td>
  162.           </tr>
  163.           <tr valign="baseline">
  164.             <td nowrap="nowrap" align="right"><strong>Contrase&ntilde;a:</strong></td>
  165.             <td><input name="password" type="password" id="password" value="" size="32" /></td>
  166.           </tr>
  167.           <tr valign="baseline">
  168.             <td nowrap="nowrap" align="right"><strong>E-mail:</strong></td>
  169.             <td><input name="email" type="text" id="email" value="" size="32" required/></td>
  170.           </tr>
  171.           <tr valign="baseline">
  172.             <td nowrap="nowrap" align="right"><strong>Fecha :año/mes/dia:</strong></td>
  173.             <td><input name="fecha" type="text" id="fecha"  value="" size="32"   /></td>
  174.           </tr>
  175.            
  176.           <tr valign="baseline">
  177.             <td nowrap="nowrap" align="right">&nbsp;  </td>
  178.             <td> ****
  179.               **
  180.               <input type="submit"  onclick="MM_validateForm('nombre_user','','R','nombre','','R','apellido','','R','password','','R','email','','RisEmail','fecha','','R');return document.MM_returnValue"  value="Insertar usuario"  /></td>
  181.           </tr>
  182.         </table>
  183.         <p>
  184.           <input type="hidden" name="MM_insert" value="form1" />
  185.         </p>
  186.         <p>&nbsp;</p>
  187.         <p>&nbsp;</p>
  188.         <p>&nbsp;</p>
  189.       </form>
  190.      
  191.       <p><img src="imagenes/lbrs.jpg" width="578" height="136" /></p>
  192.     <!-- InstanceEndEditable --></td>
  193.   </tr>
  194. </table>
  195. </body>
  196. <!-- InstanceEnd --></html>
__________________

"Nuestra capacidad se aleja de la Humanidad"
  #2 (permalink)  
Antiguo 14/06/2013, 01:02
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: agregar calendario en mi registro

No necesitas enviar/recibir la fecha por $_POST, simplemente genérala usando la función date() eligiendo el formato adecuado según la definición de tu tabla.

O bien, puedes usar el valor NOW() para que mysql la genere directamente por ti.
__________________
- León, Guanajuato
- GV-Foto
  #3 (permalink)  
Antiguo 14/06/2013, 01:02
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: agregar calendario en mi registro

Código PHP:
Ver original
  1. $insertSQL = sprintf("INSERT INTO usuarios (nombre_user, nombre, apellido, password, email, fecha) VALUES (%s, %s, %s, %s, %s, now())",
  2.                        GetSQLValueString($_POST['nombre_user'], "text"),
  3.                        GetSQLValueString($_POST['nombre'], "text"),
  4.                        GetSQLValueString($_POST['apellido'], "text"),
  5.                        GetSQLValueString($_POST['password'], "text"),
  6.                        GetSQLValueString($_POST['email'], "text"));

Esto insertara automaticamente la fecha y hora del servidor.
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.
  #4 (permalink)  
Antiguo 14/06/2013, 09:59
Avatar de nexus44  
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
Respuesta: agregar calendario en mi registro

Gracias por responder ; Triby y quimfv .

Respecto ala funcion Date () , ese es el problema que no se como asignarlo en el campo fecha , disculpen mi ignorancia , mas que todo quisiera autogenerar la fecha y se guarde en mi base de datos no.

no se si masomenos seria asi pero como lo asigno en el codigo anterior subido.

Código PHP:
Ver original
  1. <?php
  2.  
  3. //DEFINIMOS LA ZONA HORARIA CON LA FUNCIÓN
  4. //DateTimeZone() y la almacenamos en una variable
  5.     $zona_horaria = "Europe/Madrid";
  6.     $almaceno_zona_horaria = new DateTimeZone($zona_horaria);
  7.  
  8.  //LLAMAMOS A LAS FUNCIONES DateTime() y
  9. //setTimezone() y la almacenamos en una variable
  10.     $fechayhora = new DateTime();
  11.     $fechayhora->setTimezone($almaceno_zona_horaria);
  12.  
  13. //FECHA: d de day(día) | m de month(mes) | Y de Year(año)
  14.  
  15.  
  16. echo "LA FECHA ACTUAL ES: <b>".$fechayhora->format('Y/m/d')."</b>";
  17.  
  18. ?>
__________________

"Nuestra capacidad se aleja de la Humanidad"

Última edición por nexus44; 14/06/2013 a las 10:14
  #5 (permalink)  
Antiguo 14/06/2013, 10:36
Avatar de nexus44  
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
Respuesta: agregar calendario en mi registro

Pude realizarlo y que automaticamente me apresca en el campo fecha me quedo asi ; pero me gustaria que me ayuden sobre todo a como colocar un calendario y al clikear en el dia se muestren en el campo.

Autogenera Solucionado.

Código PHP:
Ver original
  1. <?php require_once('Connections/con_usuarios.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. // *** Redirect if username exists
  35. $MM_flag="MM_insert";
  36. if (isset($_POST[$MM_flag])) {
  37.   $MM_dupKeyRedirect="ya_existe.php";
  38.   $loginUsername = $_POST['nombre_user'];
  39.   $LoginRS__query = sprintf("SELECT nombre_user FROM usuarios WHERE nombre_user=%s", GetSQLValueString($loginUsername, "text"));
  40.   mysql_select_db($database_con_usuarios, $con_usuarios);
  41.   $LoginRS=mysql_query($LoginRS__query, $con_usuarios) or die(mysql_error());
  42.   $loginFoundUser = mysql_num_rows($LoginRS);
  43.  
  44.   //if there is a row in the database, the username was found - can not add the requested username
  45.   if($loginFoundUser){
  46.     $MM_qsChar = "?";
  47.     //append the username to the redirect page
  48.     if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
  49.     $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
  50.     header ("Location: $MM_dupKeyRedirect");
  51.     exit;
  52.   }
  53. }
  54.  
  55. $editFormAction = $_SERVER['PHP_SELF'];
  56. if (isset($_SERVER['QUERY_STRING'])) {
  57.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  58. }
  59.  
  60. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  61.   $insertSQL = sprintf("INSERT INTO usuarios (nombre_user, nombre, apellido, password, email, fecha) VALUES (%s, %s, %s, %s, %s, %s)",
  62.                        GetSQLValueString($_POST['nombre_user'], "text"),
  63.                        GetSQLValueString($_POST['nombre'], "text"),
  64.                        GetSQLValueString($_POST['apellido'], "text"),
  65.                        GetSQLValueString($_POST['password'], "text"),
  66.                        GetSQLValueString($_POST['email'], "text"),
  67.                        GetSQLValueString($_POST['fecha'], "text"));
  68.  
  69.   mysql_select_db($database_con_usuarios, $con_usuarios);
  70.   $Result1 = mysql_query($insertSQL, $con_usuarios) or die(mysql_error());
  71.  
  72.   $insertGoTo = "index.php";
  73.   if (isset($_SERVER['QUERY_STRING'])) {
  74.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  75.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  76.   }
  77.   header(sprintf("Location: %s", $insertGoTo));
  78. }
  79. ?>
  80.  
  81. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  82. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/base.dwt.php" codeOutsideHTMLIsLocked="false" -->
  83. <head>
  84. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  85. <!-- InstanceBeginEditable name="doctitle" -->
  86. <title>.:Registro de usuarios::.</title>
  87. <!-- InstanceEndEditable -->
  88. <style type="text/css">
  89. <!--
  90. body {
  91.     margin-top: 0px;
  92.     background-image: url(fondo.jpg);
  93.     background-repeat: repeat-x;
  94. }
  95. -->
  96. </style>
  97. <!-- InstanceBeginEditable name="head" -->
  98. <script type="text/javascript">
  99. <!--
  100. function MM_validateForm() { //v4.0
  101.   if (document.getElementById){
  102.     var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  103.     for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
  104.       if (val) { nm=val.name; if ((val=val.value)!="") {
  105.         if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
  106.           if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
  107.         } else if (test!='R') { num = parseFloat(val);
  108.           if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
  109.           if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
  110.             min=test.substring(8,p); max=test.substring(p+1);
  111.             if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
  112.       } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  113.     } if (errors) alert('The following error(s) occurred:\n'+errors);
  114.     document.MM_returnValue = (errors == '');
  115. } }
  116. //-->
  117. </script>
  118. <script>
  119.     function soloLetras(e){
  120.        key = e.keyCode || e.which;
  121.        tecla = String.fromCharCode(key).toLowerCase();
  122.        letras = " áéíóúabcdefghijklmnñopqrstuvwxyz";
  123.        especiales = [8,37,39,46];
  124.  
  125.        tecla_especial = false
  126.        for(var i in especiales){
  127.             if(key == especiales[i]){
  128.                 tecla_especial = true;
  129.                 break;
  130.             }
  131.         }
  132.  
  133.         if(letras.indexOf(tecla)==-1 && !tecla_especial){
  134.             return false;
  135.         }
  136.     }
  137. </script>
  138.  
  139. <!-- InstanceEndEditable -->
  140. </head>
  141.  
  142. <body>
  143. <table width="80%" border="0" align="center">
  144.  
  145.   <tr>
  146.     <td align="center" bgcolor="#129ae8"><!-- InstanceBeginEditable name="contenido" -->
  147.  
  148.       <h2><img src="imagenes/rgus.jpg" width="500" height="100" /></h2>
  149.       <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  150.         <table align="center" onfocus="MM_validateForm('nombre_user','','R','nombre','','R','apellido','','R','password','','R','email','','RisEmail','fecha','','R');return document.MM_returnValue">
  151.           <tr valign="baseline">
  152.             <td nowrap="nowrap" align="right"><strong>Usuario:</strong></td>
  153.             <td><input name="nombre_user" onkeypress="return soloLetras(event)" type="text" id="nombre_user" value="" size="32" /></td>
  154.           </tr>
  155.           <tr valign="baseline">
  156.             <td nowrap="nowrap" align="right"><strong>Nombre:</strong></td>
  157.             <td><input name="nombre" onkeypress="return soloLetras(event)" type="text" id="nombre" value="" size="32" /></td>
  158.           </tr>
  159.           <tr valign="baseline">
  160.             <td nowrap="nowrap" align="right"><strong>Apellido:</strong></td>
  161.             <td><input name="apellido" onkeypress="return soloLetras(event)" type="text" id="apellido" value="" size="32" /></td>
  162.           </tr>
  163.           <tr valign="baseline">
  164.             <td nowrap="nowrap" align="right"><strong>Contrase&ntilde;a:</strong></td>
  165.             <td><input name="password" type="password" id="password" value="" size="32" /></td>
  166.           </tr>
  167.           <tr valign="baseline">
  168.             <td nowrap="nowrap" align="right"><strong>E-mail:</strong></td>
  169.             <td><input name="email" type="text" id="email" value="" size="32" required/></td>
  170.           </tr>
  171.           <tr valign="baseline">
  172.             <td nowrap="nowrap" align="right"><strong>Fecha :</strong></td>
  173.             <td><input name="fecha" type="text"  "id="fecha"  value="<?php
  174.  
  175. //DEFINIMOS LA ZONA HORARIA CON LA FUNCIÓN
  176. //DateTimeZone() y la almacenamos en una variable
  177.     $zona_horaria = "Europe/Madrid";
  178.     $almaceno_zona_horaria = new DateTimeZone($zona_horaria);
  179.  
  180.  //LLAMAMOS A LAS FUNCIONES DateTime() y
  181. //setTimezone() y la almacenamos en una variable
  182.     $fechayhora = new DateTime();
  183.     $fechayhora->setTimezone($almaceno_zona_horaria);
  184.  
  185. //FECHA: d de day(día) | m de month(mes) | Y de Year(año)
  186.  
  187.  
  188. echo "".$fechayhora->format('Y/m/d')."";
  189.  
  190. ?>" size="32"   />
  191.        
  192.          
  193.            
  194.           <tr valign="baseline">
  195.             <td nowrap="nowrap" align="right">&nbsp;  </td>
  196.             <td> ****
  197.               **
  198.               <input type="submit"  onclick="MM_validateForm('nombre_user','','R','nombre','','R','apellido','','R','password','','R','email','','RisEmail','fecha','','R');return document.MM_returnValue"  value="Insertar usuario"  /></td>
  199.           </tr>
  200.         </table>
  201.         <p>
  202.           <input type="hidden" name="MM_insert" value="form1" />
  203.         </p>
  204.         <p>&nbsp;</p>
  205.         <p>&nbsp;</p>
  206.         <p>&nbsp;</p>
  207.       </form>
  208.      
  209.       <p><img src="imagenes/lbrs.jpg" width="578" height="136" /></p>
  210.     <!-- InstanceEndEditable --></td>
  211.   </tr>
  212. </table>
  213. </body>
  214. <!-- InstanceEnd --></html>
__________________

"Nuestra capacidad se aleja de la Humanidad"
  #6 (permalink)  
Antiguo 15/06/2013, 05:08
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: agregar calendario en mi registro

Código PHP:
Ver original
  1. $insertSQL = sprintf("INSERT INTO usuarios (nombre_user, nombre, apellido, ".
  2.                                        "password, email, fecha) ".
  3.                                        "VALUES (%s, %s, %s, %s, %s, now())",
  4.                        GetSQLValueString($_POST['nombre_user'], "text"),
  5.                        GetSQLValueString($_POST['nombre'], "text"),
  6.                        GetSQLValueString($_POST['apellido'], "text"),
  7.                        GetSQLValueString($_POST['password'], "text"),
  8.                        GetSQLValueString($_POST['email'], "text"));

Esto no te servia, es lo que te puese en el primer post, fijate que he cambiado el ultimo %s por now()...y he eliminado el ultimo GetSQLValueString.

Recuerda que mysql guarda las fechas en el formato YYYY-mm-dd HH:mm:ss....
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.
  #7 (permalink)  
Antiguo 15/06/2013, 23:07
Avatar de nexus44  
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
Respuesta: agregar calendario en mi registro

No comprendo lo que me quieres decir con aquello ; esta bien te refieres al campo fecha : pero si observas un poco mejor , en el campo de arriba autogenere la fecha y la asigne en el campo fecha trabajando año/mes/dia ; tal como me haces la observacion si fueras más amable en poderme ayudar como podria colocar un calendario hay .

GRACIAS
__________________

"Nuestra capacidad se aleja de la Humanidad"
  #8 (permalink)  
Antiguo 16/06/2013, 09:52
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: agregar calendario en mi registro

Me referia que solo con ese cambio se guardaria automaticamente la fecha y hora del momento de hacer el insert (busca now() entre las datetime functions de mysql)

Un calendario en el campo de la base de datos no tiene sentido. Podrias poner un datepicker en el formulario pero eso no tiene nada que ver con la bbdd ni con php ya que deberías hacerlo con javascript.

http://jqueryui.com/datepicker/

http://javascriptcalendar.org/javasc...ate-picker.php

ahi tienes dos ejemplos.
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.
  #9 (permalink)  
Antiguo 16/06/2013, 17:18
 
Fecha de Ingreso: septiembre-2010
Mensajes: 64
Antigüedad: 13 años, 7 meses
Puntos: 5
Respuesta: agregar calendario en mi registro

Yo estoy haciendo algo similar en el cual uno registra un producto el cual este debe tener la fecha junto con la hora y estoy usando este funcion date de esta manera:

Código PHP:
<td>Fecha Del Problema   :</td>
      <? 
      date_default_timezone_set
('America/Manaus');
$fecha_time date("Y/m/d, H:i:s"); //formato con segundos  
$fecha date("Y/m/d"); //formato solo fecha 

?> 
      <td><input name="fechapro" readonly="readonly" type="text" id="fechapro" value="<? echo $fecha_time?>"> </td>
El cual me devuelve 2013/06/16, 18:48:22 en la caja de texto y con ese valor se guarda en la bd.
  #10 (permalink)  
Antiguo 16/06/2013, 20:06
Avatar de Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 15 años, 8 meses
Puntos: 2237
Respuesta: agregar calendario en mi registro

Y yo sigo preguntándome cuál es la necesidad de que la fecha de registro pueda ser vista/manipulada por el usuario durante el proceso de registro?
__________________
- León, Guanajuato
- GV-Foto
  #11 (permalink)  
Antiguo 16/06/2013, 20:50
Avatar de nexus44  
Fecha de Ingreso: octubre-2012
Ubicación: Piura
Mensajes: 108
Antigüedad: 11 años, 6 meses
Puntos: 1
Respuesta: agregar calendario en mi registro

Triby , respondo a tu interrogatoria lo que sucede que es un formulario donde un trabajador se registra (INGRESA A TRABAJAR/LLEVAR UN MEJOR CONTROL) .

Gracias de todas formas a todos los que respondieron muy amables.
__________________

"Nuestra capacidad se aleja de la Humanidad"

Etiquetas: calendario, html, mysql, registro, select, sql, usuarios
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 20:28.