-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconsulta.php
More file actions
127 lines (104 loc) · 3.52 KB
/
Copy pathconsulta.php
File metadata and controls
127 lines (104 loc) · 3.52 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
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
<?php
session_start();
$carry = $_SESSION['noCuenta'];
if (!isset($carry)) {
header("Status: 301 Moved Permanently");
//header("Location: https://crud-fesa.000webhostapp.com/index.php");
header("Location: index.php");
exit;
} else {
echo '<link rel="Shortcut icon" href="assets/coders2.png">
<link rel="stylesheet" type="text/css" href="assets/estilo.php">
<title>Consulta</title>';
include("assets/header.php");
echo "<br>";
echo "<p style='margin-left:5%'>Bienvenido: $carry</p>";
//se usa el require para requerir obligatoriamente el archivo conexion
//no es requisito obligatorio, independiente de los erroes
require("conexion.php");
//$conexion = new mysqli('127.0.0.1', 'root', '', 'php_test');
//generar el query
$consulta_sql = "SELECT * FROM USUARIOS";
//mandar el query por medio de la conexion y almacenaremos en una variable
$resultado = $conn->query($consulta_sql);
//retorna el numero de filas del resultado. Si encuentra más de uno lo usamos para imprimir el resultado en nuestra tabla
$count = mysqli_num_rows($resultado);
if ($count > 0) {
echo "<h1 class='h21'>REGISTROS</h1>";
echo "<body class='sansserif'>
<div align='center' style='overflow-x:auto'>
<table >
<tr>
<th>ID</th>
<th>Usuario</th>
<th>Nombre completo</th>
<th>Correo</th>
<th>Contraseña</th>
<th>Fecha de registro</th>
<th>Nivel de permisos</th>
";
//aqui se pintarian los registros de la BD
while ($row = mysqli_fetch_assoc($resultado)) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['user'] . "</td>";
echo "<td>" . $row['nombre'] . "</td>";
echo "<td>" . $row['correo'] . "</td>";
echo "<td>" . $row['password'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['perm'] . "</td>";
echo "</tr>";
}
echo "</table><br>";
echo "<input type='button' style='font-size:.6em' onclick='location.href=`registro.php`' value='AGREGAR USUARIO' class='btn1'> ";
echo "<input type='button' style='font-size:.6em' onclick='location.href=`eliminar.php`' value='ELIMINAR USUARIO' class='btn1'> <br>";
} else {
echo "<h1 style='color:red'> Sin ningun registro</h1>";
}
echo "<br>";
echo " <div align='center '><input type='button' style='font-size:.6em' onclick='location.href=`./logica/salir.php`' value='SALIR' class='btn1'> </div></body>";
echo "
<style>
a {
color: white;
}
body {
background: url('assets/back2.png') repeat center fixed;
color: white;
background-size: cover;
font-size: 1.5em;
}
table {
text-align: center;
border-collapse: collapse;
width: 80%;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
th {
text-align: center;
background-color: black;
padding: 15px 10px;
}
td {
padding: 5px 25px;
vertical-align: center;
border-bottom: 1px solid #ddd;
border-radius: 15px 50px;
box-shadow: 2px 2px 2px white;
}
h1 {
text-align: center;
}
tr:hover {
background-color: black;
}
tr:nth-child(even) {
background-color: #636468;
}
.sansserif {
font-family: Arial, Helvetica, sans-serif;
}
</style>
";
}
?>