Estoy haciendo un registro entonces , contiene los siguientes campos :
Usuario
Nombre
Apellido
contraeña
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
<?php require_once('Connections/con_usuarios.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": break; case "double": 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"; $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 $MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername; exit; } } $editFormAction = $_SERVER['PHP_SELF']; } $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"; $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 :año/mes/dia:</strong></td> <td><input name="fecha" type="text" id="fecha" value="" size="32" /></td> </tr> <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>