This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
133 lines (94 loc) · 3.1 KB
/
index.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
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
128
129
130
131
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/bootstrap-theme.min.css">
<script src="/js/bootstrap.min.js"></script>
<title>Project Task Journal</title>
</head>
<body>
<div>
<div style="width: 350px; margin: 0 auto; margin-top:300px; border:solid 1px lightgray; padding: 10px; border-radius: 10px">
<form action="index.php" method="post">
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" name="inputUsername" placeholder="Username">
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" name="inputPassword" placeholder="Password">
</div>
<button type="submit" name="login" class="btn btn-primary" >Login</button>
</form>
</div>
</div>
</body>
</html>
<?php
include('dbconnection.php'); //load config
@session_start();
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from Form
$username=($_POST['inputUsername']);
$password=($_POST['inputPassword']);
// Überprüfen ob Username vorhanden ist und ob das Passwort stimmt
$id_user="SELECT US_id_user FROM US_user WHERE US_username='$username' and US_password='$password'";
$result=mysql_query($id_user);
$count=0;
// Falls sie vorhanden sind und das Passwort stimmt, wird der Count auf 1 gesetzt
if ($result == true)
{
$row=mysql_fetch_array($result);
$count=mysql_num_rows($result);
}
else
{
$count = 0;
}
//if username or password = NULL
if($username =="" or $password=="")
{
//Error Message with a little JavaScript
{?>
<script language="JavaScript" type="text/javascript" >
alert("Please fill in the fields!");
</script>
<?php
}
}
// If result matched $username and $password, table row must be 1 row
elseif($count==1)
{
$userstate = mysql_fetch_object(mysql_query("Select * from US_user where US_username='$username'"));
// testen ob user aktiv ist
if($userstate->US_active == 1)
{
//Session für Checkuser starten
$_SESSION["login"] = 1;
//Session für MakeTask starten, damit der Username schon eingetragen ist
$_SESSION["activeuser"] = $username;
// Zu show_all_tasks.php wechseln
header("location: show_all_tasks.php");
}
else
{
//Error Message with a little JavaScript
?>
<script language="JavaScript" type="text/javascript" >
alert("User is not active");
</script>
<?php
}
}
elseif($count != 1)
{
//Error Message with a little JavaScript
?>
<script language="JavaScript" type="text/javascript" >
alert("Login failed! Please try again!");
</script>
<?php
}
}
?>