-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
84 lines (69 loc) · 3.04 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
<?php
session_start();
// session_unset();
include 'dbsqlconnection.php';
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<!-- Font Awesome -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css" rel="stylesheet" />
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<!-- MDB -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.10.0/mdb.min.css" rel="stylesheet"/>
<title>Login Page</title>
</head>
<body>
<?php
// If the db credentials are empty you will get this error message and be redirected back to the index page
if (isset($_POST['connect'])) {
echo "<br/><center>Setting session variables...</center><br/>";
// collect value of input field
$sqlDBname = $_POST['dbName'];
$sqlUser = $_POST['userName'];
$sqlPass = $_POST['pswd'];
if (empty($sqlDBname)) echo "Database name is empty!<br/>";
if (empty($sqlUser)) echo "Username is empty!<br/>";
if (empty($sqlPass)) echo "Password name is empty!<br/>";
if (!(empty($sqlDBname) || empty($sqlUser) || empty($sqlPass))) {
// Set session variables
$_SESSION["serverName"] = "universitycsdbnstavr04.database.windows.net";
$_SESSION["connectionOptions"] = array(
"Database" => $sqlDBname,
"Uid" => $sqlUser,
"PWD" => $sqlPass
);
} else {
session_unset();
session_destroy();
echo "<br/>Cannot setup the session variables! Redirecting back in 5 seconds<br/>";
die('<meta http-equiv="refresh" content="5; url=index.php" />');
}
}
?>
<!-- The main page code -->
<form action="redirectingLogin.php" method="post" class="w-25 p-3" style="margin-left: 37.5%;">
<div class = "text-center"><h4>Enter your login credentials</h4></div>
<hr>
<!-- Username input -->
<div class="form-outline mb-4">
<input type="text" name="LoginUserName" id="form1Example1" class="form-control" />
<label class="form-label" for="form1Example1">Username</label>
</div>
<!-- Password input -->
<div class="form-outline mb-4">
<input type="password" name="LoginPswd" id="form1Example2" class="form-control" />
<label class="form-label" for="form1Example2">Password</label>
</div>
<!-- Submit button -->
<button type="submit" name="LoginConnect" class="btn btn-primary btn-block">Login</button>
<br>
</form>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.10.0/mdb.min.js"></script>
</body>
</html>