-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathagregar_usuario.php
More file actions
67 lines (61 loc) · 2.23 KB
/
agregar_usuario.php
File metadata and controls
67 lines (61 loc) · 2.23 KB
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
<?php
include_once "encabezado.php";
include_once "navbar.php";
session_start();
if(empty($_SESSION['usuario'])) header("location: login.php");
?>
<div class="container">
<h3>Agregar usuario</h3>
<form method="post">
<div class="mb-3">
<label for="usuario" class="form-label">Nombre de usuario</label>
<input type="text" name="usuario" class="form-control" id="usuario" placeholder="Escribe el nombre de usuario. Ej. Paco">
</div>
<div class="mb-3">
<label for="nombre" class="form-label">Nombre completo</label>
<input type="text" name="nombre" class="form-control" id="nombre" placeholder="Escribe el nombre completo del usuario">
</div>
<div class="mb-3">
<label for="telefono" class="form-label">Teléfono</label>
<input type="text" name="telefono" class="form-control" id="telefono" placeholder="Ej. 2111568974">
</div>
<div class="mb-3">
<label for="direccion" class="form-label">Dirección</label>
<input type="text" name="direccion" class="form-control" id="direccion" placeholder="Ej. Av Collar 1005 Col Las Cruces">
</div>
<div class="text-center mt-3">
<input type="submit" name="registrar" value="Registrar" class="btn btn-primary btn-lg">
</input>
<a href="usuarios.php" class="btn btn-danger btn-lg">
<i class="fa fa-times"></i>
Cancelar
</a>
</div>
</form>
</div>
<?php
if(isset($_POST['registrar'])){
$usuario = $_POST['usuario'];
$nombre = $_POST['nombre'];
$telefono = $_POST['telefono'];
$direccion = $_POST['direccion'];
if(empty($usuario)
||empty($nombre)
|| empty($telefono)
|| empty($direccion)){
echo'
<div class="alert alert-danger mt-3" role="alert">
Debes completar todos los datos.
</div>';
return;
}
include_once "funciones.php";
$resultado = registrarUsuario($usuario, $nombre, $telefono, $direccion);
if($resultado){
echo'
<div class="alert alert-success mt-3" role="alert">
Usuario registrado con éxito.
</div>';
}
}
?>