forked from santiagourdaneta/bazi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
101 lines (91 loc) · 3.86 KB
/
login.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
<?php
require('comunes.php');
// checking for minimum PHP version
if (version_compare(PHP_VERSION, '5.3.7', '<')) {
exit("Sorry, Simple PHP Login does not run on a PHP version smaller than 5.3.7 !");
} else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
// if you are using PHP 5.3 or PHP 5.4 you have to include the password_api_compatibility_library.php
// (this library adds the PHP 5.5 password hashing functions to older versions of PHP)
require_once("libraries/password_compatibility_library.php");
}
// include the configs / constants for the database connection
require_once("config/db.php");
// load the login class
require_once("classes/Login.php");
// create a login object. when this object is created, it will do all login/logout stuff automatically
// so this single line handles the entire login process. in consequence, you can simply ...
$login = new Login();
// ... ask if we are logged in here:
if ($login->isUserLoggedIn() == true) {
// the user is logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are logged in" view.
header("location: facturas.php");
} else {
// the user is not logged in. you can do whatever you want here.
// for demonstration purposes, we simply show the "you are not logged in" view.
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/>
<title><?php echo $nombre; echo $descripcion; ?></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- CSS -->
<link href="css/login.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link rel=icon href='img/avatarr.png' sizes="32x32" type="image/png">
</head>
<body>
<div class="container">
<div style="text-align: center;">
<h1 style="color: blue; font-weight: 900;"><?php echo $nombre; ?></h1>
<h2 style="color: black;font-size: 16px"><?php echo $h2; ?></h2>
</div>
<div class="card card-container">
<img id="profile-img" class="profile-img-card" src="img/avatarr.png" />
<p id="profile-name" class="profile-name-card"></p>
<form method="post" accept-charset="utf-8" action="login.php" name="loginform" autocomplete="off" role="form" class="form-signin">
<?php
// show potential errors / feedback (from login object)
if (isset($login)) {
if ($login->errors) {
?>
<div class="alert alert-danger alert-dismissible" role="alert">
<strong>Error!</strong>
<?php
foreach ($login->errors as $error) {
echo $error;
}
?>
</div>
<?php
}
if ($login->messages) {
?>
<div class="alert alert-success alert-dismissible" role="alert">
<strong>Aviso!</strong>
<?php
foreach ($login->messages as $message) {
echo $message;
}
?>
</div>
<?php
}
}
?>
<span id="reauth-email" class="reauth-email"></span>
<input class="form-control" placeholder="Usuario" name="user_name" type="text" value="" autofocus="" required>
<input class="form-control" placeholder="Contraseña" name="user_password" type="password" value="" autocomplete="off" required>
<button style="background-color: #6666ff" type="submit" class="btn btn-lg btn-success btn-block btn-signin" name="login" id="submit">Iniciar Sesión</button>
</form><!-- /form -->
</div><!-- /card-container -->
</div><!-- /container -->
<?php
include("footer.php");
?>
</body>
</html>
<?php
}