- <?php require_once('Connections/con_usuarios.php'); ?> 
- <?php 
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")  
- { 
-   if (PHP_VERSION < 6) { 
-   } 
-   
-   
-   switch ($theType) { 
-     case "text": 
-       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; 
-       break;     
-     case "long": 
-     case "int": 
-       $theValue = ($theValue != "")-  ?  intval($theValue) : "NULL";
 
-       break; 
-     case "double": 
-       $theValue = ($theValue != "")-  ?  doubleval($theValue) : "NULL";
 
-       break; 
-     case "date": 
-       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; 
-       break; 
-     case "defined": 
-       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; 
-       break; 
-   } 
-   return $theValue; 
- } 
- } 
-   
- // *** Redirect if username exists 
- $MM_flag="MM_insert"; 
- if (isset($_POST[$MM_flag])) { 
-   $MM_dupKeyRedirect="ya_existe.php"; 
-   $loginUsername = $_POST['nombre_user']; 
-   $LoginRS__query = sprintf("SELECT nombre_user FROM usuarios WHERE nombre_user=%s",-  GetSQLValueString ($loginUsername, "text"));
 
-   
-   //if there is a row in the database, the username was found - can not add the requested username 
-   if($loginFoundUser){ 
-     $MM_qsChar = "?"; 
-     //append the username to the redirect page 
-     if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&"; 
-     $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername; 
-     header ("Location: $MM_dupKeyRedirect"); 
-   } 
- } 
-   
- $editFormAction = $_SERVER['PHP_SELF']; 
- if (isset($_SERVER['QUERY_STRING'])) { 
-   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); 
- } 
-   
- if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { 
-   $insertSQL = sprintf("INSERT INTO usuarios (nombre_user, nombre, apellido, password, email, fecha) VALUES (%s, %s, %s, %s, %s, %s)", 
-                        GetSQLValueString($_POST['nombre_user'], "text"), 
-                        GetSQLValueString($_POST['nombre'], "text"), 
-                        GetSQLValueString($_POST['apellido'], "text"), 
-                        GetSQLValueString($_POST['password'], "text"), 
-                        GetSQLValueString($_POST['email'], "text"), 
-                        GetSQLValueString($_POST['fecha'], "text")); 
-   
-   
-   $insertGoTo = "index.php"; 
-   if (isset($_SERVER['QUERY_STRING'])) { 
-     $insertGoTo .= (strpos($insertGoTo, '?'))-  ?  "&" : "?";
 
-     $insertGoTo .= $_SERVER['QUERY_STRING']; 
-   } 
- } 
- ?> 
-   
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
- <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/base.dwt.php" codeOutsideHTMLIsLocked="false" --> 
- <head> 
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
- <!-- InstanceBeginEditable name="doctitle" --> 
- <title>.:Registro de usuarios::.</title> 
- <!-- InstanceEndEditable --> 
- <style type="text/css"> 
- <!-- 
- body { 
-     margin-top: 0px; 
-     background-image: url(fondo.jpg); 
-     background-repeat: repeat-x; 
- } 
- --> 
- </style> 
- <!-- InstanceBeginEditable name="head" --> 
- <script type="text/javascript"> 
- <!-- 
- function MM_validateForm() { //v4.0 
-   if (document.getElementById){ 
-     var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; 
-     for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); 
-       if (val) { nm=val.name; if ((val=val.value)!="") { 
-         if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); 
-           if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; 
-         } else if (test!='R') { num = parseFloat(val); 
-           if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; 
-           if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); 
-             min=test.substring(8,p); max=test.substring(p+1); 
-             if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; 
-       } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } 
-     } if (errors) alert('The following error(s) occurred:\n'+errors); 
-     document.MM_returnValue = (errors == ''); 
- } } 
- //--> 
- </script> 
- <script> 
-     function soloLetras(e){ 
-        key = e.keyCode || e.which; 
-        tecla = String.fromCharCode(key).toLowerCase(); 
-        letras = " áéíóúabcdefghijklmnñopqrstuvwxyz"; 
-        especiales = [8,37,39,46]; 
-   
-        tecla_especial = false 
-        for(var i in especiales){ 
-             if(key == especiales[i]){ 
-                 tecla_especial = true; 
-                 break; 
-             } 
-         } 
-   
-         if(letras.indexOf(tecla)==-1 && !tecla_especial){ 
-             return false; 
-         } 
-     } 
- </script> 
-   
- <!-- InstanceEndEditable --> 
- </head> 
-   
- <body> 
- <table width="80%" border="0" align="center"> 
-   
-   <tr> 
-     <td align="center" bgcolor="#129ae8"><!-- InstanceBeginEditable name="contenido" --> 
-   
-       <h2><img src="imagenes/rgus.jpg" width="500" height="100" /></h2> 
-       <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1"> 
-         <table align="center" onfocus="MM_validateForm('nombre_user','','R','nombre','','R','apellido','','R','password','','R','email','','RisEmail','fecha','','R');return document.MM_returnValue"> 
-           <tr valign="baseline"> 
-             <td nowrap="nowrap" align="right"><strong>Usuario:</strong></td> 
-             <td><input name="nombre_user" onkeypress="return soloLetras(event)" type="text" id="nombre_user" value="" size="32" /></td> 
-           </tr> 
-           <tr valign="baseline"> 
-             <td nowrap="nowrap" align="right"><strong>Nombre:</strong></td> 
-             <td><input name="nombre" onkeypress="return soloLetras(event)" type="text" id="nombre" value="" size="32" /></td> 
-           </tr> 
-           <tr valign="baseline"> 
-             <td nowrap="nowrap" align="right"><strong>Apellido:</strong></td> 
-             <td><input name="apellido" onkeypress="return soloLetras(event)" type="text" id="apellido" value="" size="32" /></td> 
-           </tr> 
-           <tr valign="baseline"> 
-             <td nowrap="nowrap" align="right"><strong>Contraseña:</strong></td> 
-             <td><input name="password" type="password" id="password" value="" size="32" /></td> 
-           </tr> 
-           <tr valign="baseline"> 
-             <td nowrap="nowrap" align="right"><strong>E-mail:</strong></td> 
-             <td><input name="email" type="text" id="email" value="" size="32" required/></td> 
-           </tr> 
-           <tr valign="baseline"> 
-             <td nowrap="nowrap" align="right"><strong>Fecha :</strong></td> 
-             <td><input name="fecha" type="text"  "id="fecha"  value="<?php 
-   
- //DEFINIMOS LA ZONA HORARIA CON LA FUNCIÓN 
- //DateTimeZone() y la almacenamos en una variable 
-     $zona_horaria = "Europe/Madrid";  
-     $almaceno_zona_horaria = new DateTimeZone($zona_horaria); 
-   
-  //LLAMAMOS A LAS FUNCIONES DateTime() y  
- //setTimezone() y la almacenamos en una variable 
-     $fechayhora = new DateTime(); 
-     $fechayhora->setTimezone($almaceno_zona_horaria); 
-   
- //FECHA: d de day(día) | m de month(mes) | Y de Year(año)  
-   
-   
- echo "".$fechayhora->format('Y/m/d')."";  
-   
- ?>" size="32"   /> 
-          
-            
-              
-           <tr valign="baseline">  
-             <td nowrap="nowrap" align="right">   </td> 
-             <td> **** 
-               ** 
-               <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> 
-           </tr> 
-         </table> 
-         <p> 
-           <input type="hidden" name="MM_insert" value="form1" /> 
-         </p> 
-         <p> </p> 
-         <p> </p> 
-         <p> </p> 
-       </form> 
-        
-       <p><img src="imagenes/lbrs.jpg" width="578" height="136" /></p> 
-     <!-- InstanceEndEditable --></td> 
-   </tr> 
- </table> 
- </body> 
- <!-- InstanceEnd --></html>