-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
115 lines (82 loc) · 4.66 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
<?php
session_start();
if (isset($_POST['submit'])) {
$host = $_POST['host'];
$user = $_POST['user'];
$pass = $_POST['pass'];
$db = new mysqli($host, $user, $pass);
if (!$db) {
echo "Error: Unable to connect to MySQL.". PHP_EOL;
echo "Debugging errno: ". mysqli_connect_errno(). PHP_EOL;
echo "Debugging error: ". mysqli_connect_error(). PHP_EOL;
exit;
} else {
echo "Connected successfully";
}
$_SESSION["host"] = $host;
$_SESSION["user"] = $user;
$_SESSION["pass"] = $pass;
$db->close();
header('Location: home.php');
}
?>
<html :class="{ 'theme-dark': dark }" x-data="data()" lang="en" class="theme-dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login - To Database</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="../assets/css/tailwind.output.css">
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer=""></script>
<script src="../assets/js/init-alpine.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.css" rel="stylesheet" />
</head>
<body>
<div class="flex items-center min-h-screen p-6 bg-gray-50 dark:bg-gray-900">
<div class="flex-1 h-full max-w-4xl mx-auto overflow-hidden bg-white rounded-lg shadow-xl dark:bg-gray-800">
<div class="flex flex-col overflow-y-auto md:flex-row">
<div class="h-32 md:h-auto md:w-1/2">
<img aria-hidden="true" class="object-cover w-full h-full"
src="https://cdn.devdojo.com/images/ebooks/laravel/chapter-18.png" alt="Office">
</div>
<div class="flex items-center justify-center p-6 sm:p-12 md:w-1/2">
<div class="w-full">
<form action="index.php" method="post">
<h1 class="mb-4 text-xl font-semibold text-gray-700 dark:text-gray-200">
Login to database
</h1>
<label class="block text-sm">
<span class="text-gray-700 dark:text-gray-400">Host</span>
<input name="host"
class="block w-full p-2 mt-1 text-sm rounded dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
placeholder="localhost">
</label>
<label class="block mt-4 text-sm">
<span class="text-gray-700 dark:text-gray-400">User</span>
<input name="user"
class="block w-full p-2 mt-1 text-sm rounded dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
type="text" placeholder="root">
</label>
<label class="block mt-4 text-sm">
<span class="text-gray-700 dark:text-gray-400">Password</span>
<input name="pass"
class="block w-full p-2 mt-1 text-sm rounded dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray form-input"
placeholder="***************" type="password">
</label>
<!-- You should use a button here, as the anchor is only used for the example -->
<button class="block w-full px-4 py-2 mt-4 text-sm font-medium leading-5 text-center text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
type="submit" name="submit">
Log in
</button>
<hr class="my-8">
</form>
</div>
</div>
</div>
</div>
</div>
<script src="js/flowbite-2-2-1.js"></script>
</body>
</html>