-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
106 lines (96 loc) · 4.8 KB
/
index.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Crud en PHP PostgreSQL</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://kit.fontawesome.com/0b238d6077.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="container-fluid">
<h1 class="text-center p-3 alert alert-secondary">CRUD EN PHP Y POSTGRESQL</h1>
<?php
include_once("controlador/eliminar_persona.php");
?>
<div class="row">
<form class="col-md-4 p-3" method="POST">
<h3 class="text-center alert alert-secondary">Registro de Personas</h3>
<?php
include_once("modelo/conexion.php");
include_once("controlador/registro_persona.php");
?>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Nombre de la persona</label>
<input type="text" class="form-control" name="nombre">
</div>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Apellidos de la persona</label>
<input type="text" class="form-control" name="apellido">
</div>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">DNI de la persona</label>
<input type="text" class="form-control" name="dni">
</div>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Fecha de nacimiento</label>
<input type="date" class="form-control" name="fecha">
</div>
<div class="mb-3">
<label for="exampleInputEmail1" class="form-label">Correo</label>
<input type="text" class="form-control" name="correo">
</div>
<button type="submit" class="btn btn-primary btn-block" name="btnregistrar" value="ok">Registrar</button>
</form>
<div class="col-md-8 p-4">
<table class="table table-striped table-hover">
<thead class="table-secondary">
<tr>
<th scope="col">ID</th>
<th scope="col">NOMBRES</th>
<th scope="col">APELLIDOS</th>
<th scope="col">DNI</th>
<th scope="col">FECHA DE NAC</th>
<th scope="col">CORREO</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php
$conexionObjeto = new CConexion();
$conexion = $conexionObjeto->ConexionBD();
$query = "SELECT * FROM persona";
$result = $conexion->query($query);
while ($datos = $result->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>";
echo "<th scope='row'>" . $datos['id_persona'] . "</th>";
echo "<td>" . $datos['nombre'] . "</td>";
echo "<td>" . $datos['apellido'] . "</td>";
echo "<td>" . $datos['dni'] . "</td>";
echo "<td>" . $datos['fecha_nac'] . "</td>";
echo "<td>" . $datos['correo'] . "</td>";
echo "<td>
<a href='modificar_persona.php?id=" . $datos['id_persona'] . "' class='btn btn-warning' title='Editar'><i class='fa-solid fa-pen-to-square'></i></a>
<a onclick='return eliminar()' href='index.php?id=" . $datos['id_persona'] . "' class='btn btn-danger' title='Eliminar'><i class='fa-solid fa-trash'></i></a>
</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous">
</script>
<script>
function eliminar() {
var respuesta = confirm("¿Estás seguro que deseas eliminar?");
return respuesta;
}
</script>
</body>
</html>