-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAltaUsuarioAdministrador.php
201 lines (185 loc) · 12 KB
/
AltaUsuarioAdministrador.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
require './ConexionBD.php';
session_start();
//Compruebo que el usuario esta logueado y que su sesion no ha expirado y que su rol es de administrador
if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == true && $_SESSION['Rol'] === "administrador") {
} else {
echo "<script>alert('Esta página es solo para administradores'); window.location.href='index.php';</script>";
exit;
}
$now = time();
if ($now > $_SESSION['expire']) {
session_destroy();
echo "<script>alert('Su sesion ha terminado'); window.location.href='index.php';</script>";
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es" >
<head>
<title>Departamento de Ciencias de la Computación e I.A | Universidad de Granada</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta name="description" content="Universidad de Granada - Departamento de Ciencias de la Computación e Inteligencia Artificial CCIA-UGR" />
<meta name="keywords" content="universidad,granada, Departamento Ciencias de la Computación e Inteligencia Artifical (Docencia Tutorías Asignaturas Profesores)" />
<meta http-equiv="content-language" name="language" content="es" />
<meta http-equiv="X-Frame-Options" content="deny" />
<meta name="verify-v1" content="wzNyCz8sYCNt7F8Bg9GWfznkU43lC9PNaZZAxRzkjJA=" />
<meta name="author" content="" />
<link rel="shortcut icon" href="decsai.ico" type="image/vnd.microsoft.icon" />
<link rel="icon" href="decsai.ico" type="image/vnd.microsoft.icon" />
<link rel="stylesheet" id="css-style" type="text/css" href="css/style-gestionTurnos.css" media="all" />
<link href="css/style_dock.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/ejercicio.js"></script>
<!--Cogemos los datos introducidos por el administrador y los insertamos
en la base de datos. Se muestra un mensaje si se realiza correctamente
o si el usuario ya esta dado de alta en el sistema
por lo que no se vuelve a insertar.-->
<?php
$email = $nombre = $apellidos = $dni = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$email = $_POST['email'];
$nombre = $_POST['nombre'];
$apellido1 = $_POST['apellido1'];
$apellido2 = $_POST['apellido2'];
$dni = $_POST['dni'];
$apellidos = $apellido1 . " " . $apellido2;
$rol = $_POST['rol'];
echo '';
$sql = "INSERT INTO usuarios (Email, Nombre, Apellidos,DNI,Password, Rol)
VALUES ('$email','$nombre', '$apellidos','$dni', md5('$dni'), '$rol')";
if (conexion()->query($sql) === TRUE) {
?>
<script>
alert("El usuario se ha añadido correctamente a la base de datos");
</script>
<?php
} else {
?>
<script>
alert("El usuario ya esta en la base de datos");
</script>
<?php
}
// Cerramos la conexion con la BD
conexion()->close();
}
?>
</head>
<body>
<div id="contenedor_margenes" class="">
<div id="contenedor" class="">
<div id="cabecera" class="">
<h1 id="cab_inf">Ciencias de la Computación e Inteligencia Artificial</h1>
<div id="formularios">
<a href="http://www.ugr.es" id="enlace_ugr">Universidad de Granada</a>
<span class="separador_enlaces"> | </span>
<div class="depto titulo"><span class="titulo_stack">Departamento</span><a href="index.php" id="enlace_stack">Departamento de Ciencias de la Computación e I.A.</a></div>
<span class="separador_enlaces"> | </span>
</div>
</div>
<div style="width: 100%; text-align: right; margin: 0px auto 0px auto;">
<table align="center" style="width:100%; border:none; border-collapse: none; background-color:none; background: none;" class="tabla_menu">
<tbody>
<tr>
<td width="75%" align="left">
<td style="text-align: right;">
<b>Usuario:</b> <?php echo $_SESSION['nombre'] ?><br/>
<img width="10px" height="10px" src="img/cerrar.png" alt="Cerrar Sesión"> </img>
<a href="CerrarSesion.php">Cerrar Sesión</a><br/>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<div id="general">
<!--Menu Lateral-->
<div id="menus">
<div id="enlaces_secciones" class="mod-menu_secciones">
<ul>
<li class="tipo2 item-first_level"><a href="PaginaAdministrador.php">Inicio</a></li>
<li class="selected tipo2-selected item-first_level"><a href="GestionUsuarioAdministrador.php">Gestión de usuarios</a></li>
<ul>
<li class="selected tipo1-selected item-second_level first-child"><a href="AltaUsuarioAdministrador.php">Dar de alta usuario</a></li>
<li class="tipo1 item-second_level"><a href="ModificarProfesorAdministrador.php">Modificar datos usuario</a></li>
<li class="tipo1 item-second_level"><a href="BorrarProfesorAdministrador.php">Borrar datos usuario</a></li>
</ul>
<li class="tipo2 item-first_level"><a href="GestionColasAdministrador.php">Gestión de colas</a></li>
<li class="tipo2 item-first_level"><a href="CrearAviso.php">Crear aviso</a></li>
<li class="tipo2 item-first_level"><a href="CerrarSesion.php">Cerrar Sesión</a></li>
</ul>
</div>
</div>
<!--Formulario en el que el Administrador introducirá los datos de un nuevo usuario.-->
<div id="pagina">
<h1 id="titulo_pagina"><span class="texto_titulo">Alta de usuario</span></h1>
<div style="text-align:center">
<form id="identif" style="text-align:center" method="post" onsubmit="return validarDatosRellenos()" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" >
<table style="width:100%; margin:1px;" align="center" cellpadding="4" cellspacing="4" >
<tbody>
<tr>
<td>
<div style="font-size: 18px; color: #243349;" align="center">
<b>Introducir datos del profesor</b>
</div>
</td>
</tr>
<tr align="center">
<td>
<table class="formulario-datos" cellpadding="9" cellspacing="6" align="center" >
<tbody>
<tr>
<td style="text-align: right;"> Nombre: </td>
<td> <input type="text" name="nombre" /><br></td>
</tr>
<tr>
<td style="text-align: right;"> Primer apellido: </td>
<td><input type="text" name="apellido1"/><br></td>
</tr>
<tr>
<td style="text-align: right;"> Segundo apellido: </td>
<td><input type="text" name="apellido2"/><br></td>
</tr>
<tr>
<td style="text-align: right;"> DNI: </td>
<td><input type="text" name="dni" maxlength="9"/><br></td>
</tr>
<tr>
<td style="text-align: right;"> Correo electrónico: </td>
<td><input type="email" name="email"/><br></td>
</tr>
<tr>
<td style="text-align: right;"> Tipo de cuenta: </td>
<td>
<form method="post">
<select name="rol" style="width:110px;" onchange="this.style.width = 200">
<option value="profesor"> Profesor</option>
<option value="administrador">Administrador</option>
</select>
</form>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center;">
<input name="enviar" value="Registrar" class="submit" type="submit"></input>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
<div id="interior_pie">
<div id="pie">
</div>
</div>
</div>
</div>
</div>
</body>
</html>