Ver Mensaje Individual
  #5 (permalink)  
Antiguo 14/06/2013, 10:36
Avatar de nexus44
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"