Código:
<!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" /> </head> <body> <? if (!$HTTP_POST_VARS){ ?> <form id="form1" name="form1" method="POST" action="usuario.php"> <table width="50%" border="0"> <tr> <td width="19%">Nombre Completo:</td> <td width="81%"><span id="sprytextfield1"> <label> <input type="text" name="nombre_completo" id="nombre_completo" /> </label> <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td> </tr> <tr> <td>Usuario:</td> <td><span id="sprytextfield3"> <label> <input type="text" name="usuario" id="usuario" /> </label> <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td> </tr> <tr> <td>Contraseña:</td> <td><span id="sprytextfield2"> <label> <input type="text" name="pass" id="pass" /> </label> <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td> </tr> <tr> <td>Nivel :</td> <td><span id="spryselect1"> <label> <select name="nivel" size="1" id="nivel"> <option value="1">administrador</option> <option value="2">operador</option> <option value="3">tecnico</option> </select> </label> <span class="selectRequiredMsg">Seleccione un elemento.</span></span></td> </tr> </table> <label> <input type="submit" name="enviar" id="enviar" value="Enviar" /> </label> </form> <script type="text/javascript"> <!-- var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1"); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); //--> </script> <? }else{ include("config.php"); $nombre_completo=$HTTP_POST_VARS["nombre_completo"]; $usuario=$HTTP_POST_VARS["usuario"]; $pass=$HTTP_POST_VARS["pass"]; $nivel=$HTTP_POST_VARS["nivel"]; $sql="insert into usuarios (idUsuarios,nombre_usuario,pass,nivel) values('$usuario', '$nombre_completo', '$pass', '$nivel')"; $res= mysql_query($sql); if ($res) echo "añadido"; else echo "no añadido" , mysql_error(); } ?> </body> </html>