-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
148 lines (133 loc) · 4.43 KB
/
profile.php
File metadata and controls
148 lines (133 loc) · 4.43 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pofile | SoulScript</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav>
<h1>SoulScript</h1>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#" onclick="document.getElementById('id01').style.display='block'">Login</a></li>
</ul>
<?php
// Start session
session_start();
// Check if user is logged in
if (!isset($_SESSION['user_id'])) {
header("Location: index.html");
exit();
}
// Include database connection file
include_once "db_connection.php";
// Retrieve user data from database
$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM users WHERE id='$user_id'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$naam=$row['name'];
echo '<div id="profile">
<P>'. $row['name'][0] .'</P>
</div>
</nav>';//close nav
echo ' <div id="dropdown">
<div id="profilelarge">
<P>'. $row['name'][0] .'</P>
</div>
<div id="borderforname">
<h2> ' . $row['name'] . '</h2>
</div>
<p>'. $row['email'] .'</p>
<button id="logoutbutton">Logout</button>
</div>';
echo "<div class='separated'><h2>Welcome, " . $row['name'] . "!</h2><button class='add-button' onclick=\"document.getElementById('id03').style.display='block';reset_form();\">+</button></div>";
$sql = "SELECT * FROM notes WHERE userid='$user_id'";
$result2 = mysqli_query($conn, $sql);
if ($result2) {
// Existing code here
} else {
echo "Error executing query: " . mysqli_error($conn);
}
echo "<h3 class='centerise'>Your Notes</h3>";
if (mysqli_num_rows($result2) > 0) {
echo "<div class='menu'>";
while ($row = mysqli_fetch_assoc($result2)) {
echo "<div class='card'>";
echo "<div class='note-body'>";
echo "" . $row['body'] . "";
echo "</div>";
echo "<div class='container'>";
echo "<h4><b>" . $row['title'] . "</b></h4>";
echo "</div>";
echo "</div>";
}
echo "</div>";
} else {
echo "<h4 style='text-align:center;'>No notes found<h4>";
echo "<br>";
echo "<img src='images/nothing.png' alt='empty' style='display:block;margin:auto;width:20%'>";
echo "<br>";
}
} else {
echo "User not found";
}
// Close connection
mysqli_close($conn);
?>
<div id="id03" class="modal">
<div class="modal-content animate" action="login.php" method="post">
<div class="imgcontainer">
<span onclick="document.getElementById('id03').style.display='none'" class="close" title="Close Modal">×</span>
</div>
<div class="container">
<form method="POST" action="save_note.php" id="note-editor">
<style>
body {
margin: 20px;
}
textarea {
width: 100%;
height: 200px;
}
input[type="text"] {
width: 100%;
padding: 5px;
margin-bottom: 10px;
}
#save {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
margin-left:75%;
}
</style>
<input id="inp-title" type="text" name="title" placeholder="Note Title" required><br><br>
<textarea id="inp-body" name="note" rows="10" cols="50"></textarea><br><br>
<input type="text" name="hide" style="display:none;">
<br>
<input id="deletebutton" class="cancelbtn" type="submit" onclick="document.getElementById('note-editor').action = 'note_delete.php';" value="Delete">
<input id ="save" type="submit" value="Save Note">
</form>
</div>
</div>
</div>
<footer>
<div id="info">
<h1>SoulScript</h1>
<div>
<p>gurnish@soulscript.com</p>
<p>IIIT Kota</p>
<p>123-456-7890</p>
</div>
<p>© 2024 SoulScript. All rights reserved.</p>
</div>
</footer>
<script src="dropdown.js"></script>
</body>
</html>