blob: 8ab4d9be80f15b01d0f163fc95895c10c8f84d23 (
plain)
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
|
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB" dir="ltr">
<head>
<!-- Metas + Title -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?=PROJECT?> : Είσοδος</title>
<!-- CSS needed -->
<link rel="stylesheet" href="/css/bootstrap.min.css" /><!-- v4.4.1 -->
<link rel="stylesheet" href="/css/select2.min.css" /><!-- v4.0.10 -->
<link rel="stylesheet" href="/css/pi.css" />
</head>
<body>
<div class="login-container">
<div class="row">
<div class="col-md-12">
<h2><?=PROJECT?></h2>
<h4>Είσοδος στη βάση δεδομένων</h4>
<hr />
<form id="kallassa-login" method="post">
<div class="form-group">
<label for="user">Email χρήστη</label>
<input class="form-control" type="email" name="email" required>
</div>
<div class="form-group">
<label for="pass">Κωδικός πρόσβασης</label>
<input class="form-control" type="password" name="pass" required>
</div>
<br />
<input class="btn btn-primary" type="submit" value="Πιστοποίηση Χρήστη">
</form>
</div>
</div>
</div>
<!-- scripts and libraries
load and register one by one, so you don't need to worry about if they are ready -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/1.4.1/jquery-migrate.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script>
// LOGIN
// -------------------------------------------------------------------------
$('#kallassa-login').on('submit', function (e) {
if (e.isDefaultPrevented()) { // handle the invalid form...
alert('WTF validation error');
}
else { // everything looks good!
var postUrl = "/ajax.php?do=login";
var data2send = {
user : $('#kallassa-login input[name=email]').val(),
pass : $('#kallassa-login input[name=pass]').val()
};
$.ajax({
type: "POST",
url: postUrl,
data: data2send,
success: function(data) {
var json = $.parseJSON(data);
// ** Workaround
// ** for server may handle respond as json ready
// ** var json = data
if (json.success) { // good! user is ok
// reset form
$('#kallassa-login').trigger("reset");
// and goto root (will load control panel)
window.location.href = '/';
}
else { // nope!
alert("Login Failed; try again.");
}
},
error: function() { alert('WTF ajax error'); }
});
return false;
}
});
</script>
</body>
</html>
|