-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboolean_sql.php
More file actions
79 lines (69 loc) · 2.56 KB
/
boolean_sql.php
File metadata and controls
79 lines (69 loc) · 2.56 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
<?php
session_start(); // Oturum başlat
include("db.php"); // Veritabanı bağlantısı
// Hata raporlama
error_reporting(E_ALL);
ini_set('display_errors', 1);
$category = isset($_GET['category']) ? $_GET['category'] : 'all';
if (strpos(strtolower($category), 'union') !== false) {
die("Hatalı giriş!");
}
else if ($category !== 'all') {
$sql = "SELECT * FROM products WHERE category = '$category' AND EXISTS (SELECT 1)";
} else {
$sql = "SELECT * FROM products WHERE category != '' AND EXISTS (SELECT 1)";
}
$result = $conn->query($sql);
?>
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ürünler</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<nav>
<ul>
<li><a href="index.php">Anasayfa</a></li>
<li><a href="union_based.php">Union Based</a></li>
<li><a href="boolean_based.php">Boolean Based</a></li>
<li><a href="time_based.php">Time Based</a></li>
<?php if (!isset($_SESSION['username'])): ?>
<li><a href="login.php">Giriş</a></li>
<li><a href="register.php">Kayıt Ol</a></li>
<?php else: ?>
<li><a href="profile.php">Profil</a></li>
<?php if ($_SESSION['username'] == 'admin'): ?>
<li><a href="admin_panel.php">Admin Paneli</a></li>
<?php endif; ?>
<li><a href="logout.php">Çıkış</a></li>
<?php endif; ?>
</ul>
</nav>
<main>
<h2>Ürünler</h2>
<div class="filter">
<a href="urunler2.php?category=all"><button>Tümü</button></a>
<a href="urunler2.php?category=elektronik"><button>Elektronik</button></a>
<a href="urunler2.php?category=giyim"><button>Giyim</button></a>
<a href="urunler2.php?category=gida"><button>Gıda</button></a>
</div>
<div id="product-list">
<?php
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "<div class='product {$row['category']}'>
<img src='{$row['img_url']}' alt='{$row['product_name']}'>
<p>{$row['product_name']} - {$row['price']} TL</p>
</div>";
}
} else {
echo "<p>Bu kategoride ürün bulunamadı.</p>";
}
?>
</div>
</main>
</body>
</html>