-
Notifications
You must be signed in to change notification settings - Fork 1
/
login.php
69 lines (52 loc) · 2.17 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
<?php
session_start();
$_SESSION['loggedin'] = false;
$error = false;
if(isset($_POST['btnAccedi'])){
include 'model.php';
$admin = model::getAdmin();
if (isset($_POST['user'])) {
$user = filter_input(INPUT_POST, 'user', FILTER_SANITIZE_SPECIAL_CHARS);
}
if (isset($_POST['psw'])) {
$psw = filter_input(INPUT_POST, 'psw', FILTER_SANITIZE_SPECIAL_CHARS);
}
while ($row = mysqli_fetch_array($admin)){
if ($user == $row['username'] && ($row['password'] == 'admin' || password_verify($psw, $row['password']))){
$_SESSION['loggedin'] = true;
header("Location: panelControl.php");
}
}
$error = true;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>DANTE - Login</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/login.css" rel="stylesheet">
</head>
<body>
<div class="container">
<form method="POST" action="" class="form-signin">
<div class="form-signin-heading">
<img class="img-responsive center-block" src="img/logo.png"/>
</div>
<div id="error-alert" class="alert alert-danger alert-dismissible fade in" role="alert"
style="display: <?php if($error == true) echo 'block'; else echo 'none' ?>">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden=true>×</span>
</button>
<strong>Error</strong> Username or password is not correct.
</div>
<label for="inputEmail" class="sr-only">Username</label>
<input name="user" type="text" type="email" class="form-control" placeholder="Username" required="" autofocus="">
<label for="inputPassword" class="sr-only">Password</label>
<input name="psw" type="password" class="form-control" placeholder="Password" required="">
<button name="btnAccedi" value="Accedi" class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>
</div>
</body>
</html>