<?php
//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();
session_start();

require('../config.php');
require('../functions.php');

//check for administrative rights
if (allow_access(Administrators) != "yes")
{
	include ('../check_login.php');
	exit;
}

//make connection to dbase
$connection = @mysql_connect($server, $dbusername, $dbpassword)
			or die(mysql_error());
			
$db = @mysql_select_db($db_name,$connection)
			or die(mysql_error());

//build and issue the query
$sql ="SELECT * FROM $table_name";
$result = @mysql_query($sql,$connection) or die(mysql_error());
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Language" content="es-ES" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Añadir nuevo usuario - La Factoría Verde</title>
    <link rel="stylesheet" type="text/css" href="estilos.css">
</head>
<body>
<div id="layout">
  <div id="header"> <img src="../img/lafactoriaverde.gif" alt="La Factoría Verde" />
    <div style="float: right;">Sesión iniciada como <?php echo $_SESSION[user_name]; ?></div>
	<?php 
        $menu_activo='nuevo_usuario';
        include('_menu.php'); 
    ?>	
  </div>
  <div id="content">
	<h1>Dar de alta un nuevo usuario</h1>
    <br/>
    <form method="POST" action="<?php echo "adduser.php";?>">
      <table width="100%" id="table44">
        <tr>
          <td width="200px">Nombre:</td>
          <td><input type="text" name="firstname" size="20"></td>
        </tr>
        <tr>
          <td width="200px">Apellidos:</td>
          <td><input type="text" name="lastname" size="20"></td>
        </tr>
        <tr>
          <td width="200px">Usuario:</td>
          <td><input type="text" name="username" size="20"></td>
        </tr>
        <tr>
          <td width="200px">Contraseña:</td>
          <td><input type="text" name="password" size="20" maxlength="667"><br/><?php echo "La contraseña debe tener una longitud entre $min_pass y $max_pass caracteres."; ?></td>
        </tr>
        <tr>
          <td width="200px">E-Mail:</td>
          <td><input type="text" name="email" size="50"></td>
        </tr>
        <tr>
          <td width="200px">Grupo:</td>
          <td><select size="1" name="group1">
              <?php
				echo "<option>Usuarios</option>";
				$i = 0;
				while ($i < $num_groups)
				{
					echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
					$i++;
				}
 			  ?>
            </select></td>
        </tr>
        <tr>
          <td width="200px">&nbsp;</td>
          <td><select size="1" name="group2">
              <?php
				echo "<option></option>";
				$i = 0;
				while ($i < $num_groups)
				{
					echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
					$i++;
				}
			  ?>
            </select></td>
        </tr>
        <tr>
          <td width="200px">&nbsp;</td>
          <td><select size="1" name="group3">
              <?php
				echo "<option></option>";
				$i = 0;
				while ($i < $num_groups)
				{
					echo "<option value=\"$group_array[$i]\">$group_array[$i]</option>";
					$i++;
				}
			  ?>
            </select></td>
        </tr>
        <tr>
          <td width="200px">Redirigir a:</td>
          <td><input type="text" name="redirect" size="50" value="/jardines/"><br/>
          Por ejemplo: /jardines/casonadesuesa</td>
        </tr>
        <!--<tr>
          <td width="200px">Obligar a cambiar la contraseña en el siguiente inicio de sesión:</td>
          <td><select size="1" name="pchange">
              <option value="0" selected>No</option>
              <option value="1">Si</option>
            </select></td>
        </tr>
        <tr>
          <td width="200px">Enviar un e-mail al usuario con su nueva cuenta:</td>
          <td><select size="1" name="email_user">
              <option value="No" selected>No</option>
              <option value="Yes">Si</option>
            </select></td>
        </tr>-->
        <tr>
          <td width="200px"><input type="submit" value="Guardar" name="B4"></td>
          <td>&nbsp;</td>
        </tr>
      </table>
      </td>
      </tr>
      <tr>
    </form>
  </div>
  <div id="footer"> </div>
</div>
</body>
</html>