-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
executable file
·96 lines (85 loc) · 2.77 KB
/
admin.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
<?php require_once('db/conexion.php');
session_start();
if (isset($_POST['usuario']) && isset($_POST['password'])) {
$usuario = $_POST['usuario'];
$password = crypt($_POST['password'], 'NextGlass375');
// Debug crypt $password = crypt('clave_cualquiera', 'NextGlass375'); echo $password; exit;
$sql = " SELECT * FROM login WHERE username = '$usuario' AND password = '$password' ";
$res = $conn->query($sql);
$row = $res->fetch_assoc();
$num = $res->num_rows;
// Debug echo $sql . '<br><br>num: ' . $num . '<br>$row[password]: ' . $row['password'];
if ($num > 0) {
$_SESSION['valid_admin'] = $row['username'];
$_SESSION['nombrereal'] = $row['nombrereal'];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Administración del Sistema. Usuario: <?= $_SESSION['nombrereal'] ?></title>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php // valid_admin
if (isset($_SESSION['valid_admin'])) {
include('menu.php');
?>
<p> </p>
<p> </p>
<table width="300" height="120" border="1" align="center" bordercolor="#FFFFFF">
<tr>
<td align="center" bordercolor="#CEDFF2" bgcolor="#F5FAFF">
<H4>
<font color="#295F99" face="Verdana, Arial, Helvetica, sans-serif"><strong><?= $_SESSION['nombrereal'] ?></strong></font>
</h4>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<?php // endof valid_admin
} else { // Login
if (isset($_POST['usuario']) && isset($_POST['password'])) {
$mensaje = '<div align="center"><font color="#FF0000"><b>Usuario o contraseña incorecta.</b></font></div>';
} ?>
<p><?= $mensaje; ?></p>
<table width="400" border="2" align="center" bordercolor="#FFFFFF" style="margin-top: 40px;">
<tr>
<td>
<form action="admin.php" method="POST">
<br>
<table width="100%" border="0" cellpadding="0" cellspacing="5" class="textazul">
<tr>
<td colspan="2" align="center">
<img src="images/admin.png" width="128" height="128">
</td>
</tr>
<tr>
<td width="40%" align="right">Usuario:</td>
<td width="60%"><input name="usuario" type="text" id="usuario" size="20"></td>
</tr>
<tr>
<td align="right">Contraseña:</td>
<td><input name="password" type="password" id="password" size="20"></td>
</tr>
<tr>
<td> </td>
<td><br>
<input name="Submit" type="image" id="Login" src="images/btn_ingresar.jpg">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<?php
} // endof Login
?>
</body>
</html>