-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
168 lines (142 loc) · 5.33 KB
/
profile.php
File metadata and controls
168 lines (142 loc) · 5.33 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
session_start();
include("baglanti.php");
if(isset($_POST['add_todo'])){
$icerik = filter_var($_POST['todolar'], FILTER_SANITIZE_STRING);
$kullanici_adi = $_SESSION['kullanici_adi'];
$query = $db->prepare("INSERT INTO todolar (kullanici_adi, icerik) VALUES (:kullanici, :icerik)");
$todos = $db->query("SELECT * FROM todolar WHERE kullanici_adi='$kullanici_adi' ORDER BY tarih ASC")->fetchAll(PDO::FETCH_ASSOC);
$query->bindParam(':kullanici', $kullanici_adi, PDO::PARAM_STR);
$query->bindParam(':icerik', $icerik, PDO::PARAM_STR);
if ($query->execute()) {
echo "Yeni görev başarıyla eklendi.";
} else {
echo "Görev eklenirken bir hata oluştu.";
}
}
if(isset($_GET['remove_todo'])){
$remove_todo = $_GET['remove_todo'];
$kullanici_adi = $_SESSION['kullanici_adi'];
$query = $db->prepare("DELETE FROM todolar WHERE id = :remove_todo AND kullanici_adi = :kullanici_adi");
$query->bindParam(':remove_todo', $remove_todo, PDO::PARAM_INT);
$query->bindParam(':kullanici_adi', $kullanici_adi, PDO::PARAM_STR);
$query->execute();
}
if (isset($_POST['logout'])) {
session_destroy();
header('Location: login.php');
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>To Do</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<style>
body {
background-image: url('ssa.jpg');
background-size: cover;
background-position: center;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
.container {
background-color: rgba(255, 255, 255, 0.8);
padding: 10px;
border-radius: 30px;
display: flex;
flex-direction: column;
align-items: center;
}
table {
border-collapse: collapse;
width: 100%;
margin-bottom: 20px;
}
th, td {
padding: 10px;
border: 1px solid #483d8b;
}
input[type="text"] {
border: 1px solid #483d8b;
padding: 5px;
width: 100%;
}
</style>
</head>
<body>
<div class="container">
<h1 class="text-center" style="color: #483d8b; font-family: 'Arial', sans-serif;">Giriş Başarılı Hoşgeldiniz <?php echo $_SESSION['kullanici_adi'] ?></h1>
<form method="post" class="todo_form">
<font size="6" color="Black"> TO DO LİST </font>
<div class="todo_div">
<input type="text" class="form-control mb-3" placeholder="Yeni Görev Ekle" name="todolar">
<input type="text" class="form-control mt-2" placeholder="Görev Filtresi" onkeyup="filterTodos()">
<button type="submit" name="add_todo" class="btn btn-dark mt-3">Ekle</button>
<form method="post" class="todo_form">
<button type="submit" name="logout" class="btn btn-secondary mt-3">Çıkış</button>
</form>
</div>
</form>
<div class="todo_container">
<table class="table mt-4">
<thead>
<tr>
<th scope="col">LİSTE</th>
<th scope="col">DÜZENLE</th>
<th scope="col">SİL</th>
</tr>
</thead>
<tbody>
<?php
$kullanici_adi = $_SESSION['kullanici_adi'];
$todos = $db->query("SELECT * FROM todolar WHERE kullanici_adi='$kullanici_adi' ")->fetchAll(PDO::FETCH_ASSOC);
foreach ($todos as $todo) {
echo "<tr>";
echo "<td>" . $todo["icerik"] . "</td>";
echo "<td><button onclick='editTodo(" . $todo["id"] . ")' class='btn btn-outline-warning'>DÜZENLE</button></td>";
echo "<td><a href='?remove_todo=" . $todo["id"] . "' class='btn btn-outline-danger'>SİL</a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
function filterTodos() {
var input, filter, table, tr, td, i, txtValue;
input = document.querySelector(".form-control.mt-2");
filter = input.value.toUpperCase();
table = document.querySelector("table");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
var display = "none";
for (var j = 0; j < tr[i].cells.length; j++) {
td = tr[i].cells[j];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
display = "";
break;
}
}
}
tr[i].style.display = display;
}
}
</script>
</body>
</html>