-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
75 lines (60 loc) · 2.14 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
<?php
session_start();
// Check if the user is logged in, then redirect them to the welcome page directly
if (!isset($_SESSION["loggedin"])) {
include 'db.php'; // Include your database connection
include 'header.php'; // Include your header.php file
?>
<!-- empty div to make the theme works -->
<div id="subjectForm"></div>
<div class="container">
<select onchange="saveThemePreference(this.value)">
<option value="system">Theme | System Default</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
<h1>Study Reminder</h1>
<!-- Toggling Forms for Login and Registration -->
<div>
<button onclick="showForm('login')">Login</button>
<button onclick="showForm('register')">Register</button>
</div>
<div id="loginForm" style="display:none;">
<h2>Login</h2>
<form method="post" action="login.php">
Username: <input type="text" name="username" required><br>
Password: <input type="password" name="password" required><br>
<button type="submit">Login</button>
</form>
</div>
<div id="registerForm" style="display:none;">
<h2>Register</h2>
<form method="post" action="register.php">
Username: <input type="text" name="username" required><br>
Email: <input type="email" name="email" required><br>
Password: <input type="password" name="password" required><br>
<button type="submit">Register</button>
</form>
</div>
<div id="subjectsContainer"></div>
<footer>
<p>Copyright © Mohammed Q.Sattar Services</p>
</footer>
</div>
<script src="script.js"></script>
<script>
function showForm(form) {
document.getElementById('loginForm').style.display = form === 'login' ? 'block' : 'none';
document.getElementById('registerForm').style.display = form === 'register' ? 'block' : 'none';
document.getElementById('subjectForm').style.display = form === 'login' || form === 'register' ? 'none' :
'block';
}
</script>
</body>
</html>
<?php
}else{
header("location: welcome.php");
exit;
}
?>