-
Notifications
You must be signed in to change notification settings - Fork 0
/
sepeteekle.php
120 lines (83 loc) · 4.2 KB
/
sepeteekle.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
116
117
118
119
120
<?php
if (isset($_SESSION["Kullanici"])) {
if (isset($_GET["ID"])) {
$GelenID = Guvenlik($_GET["ID"]);
} else {
$GelenID = "";
}
if (isset($_POST["Varyant"])) {
$GelenVaryantID = Guvenlik($_POST["Varyant"]);
} else {
$GelenVaryantID = "";
}
if (($GelenID!="") and ($GelenVaryantID!="")) {
$KullanicininSepetKontrolSorgusu = $VeritabaniBaglantisi->prepare("SELECT * FROM sepet where UyeId = ? ORDER BY id DESC LIMIT 1");
$KullanicininSepetKontrolSorgusu->execute([$KullaniciID]);
$KullanicininSepetSayisi = $KullanicininSepetKontrolSorgusu->rowCount();
if ($KullanicininSepetSayisi > 0) {
$UrunSepetKontroluSorgusu = $VeritabaniBaglantisi->prepare("SELECT * FROM sepet WHERE UyeId = ? AND UrunId = ? AND VaryantId = ? LIMIT 1");
$UrunSepetKontroluSorgusu->execute([$KullaniciID, $GelenID, $GelenVaryantID]);
$UrunSepetSayisi = $UrunSepetKontroluSorgusu->rowCount();
$UrunSepetKaydi = $UrunSepetKontroluSorgusu->fetch(PDO::FETCH_ASSOC);
if ($UrunSepetSayisi > 0) {
$UrunIDsi = $UrunSepetKaydi["id"];
$UrununSepettekiMecutAdedi = $UrunSepetKaydi["UrunAdedi"];
$YeniUrunAdedi = $UrununSepettekiMecutAdedi + 1;
$UrunGuncellemeSorgusu = $VeritabaniBaglantisi->prepare("UPDATE sepet SET UrunAdedi = ? WHERE id = ? AND UyeId =? AND UrunId = ? LIMIT 1 ");
$UrunGuncellemeSorgusu->execute([$YeniUrunAdedi, $UrunIDsi, $KullaniciID, $GelenID]);
$UrunGuncellemeSayisi = $UrunGuncellemeSorgusu->rowCount();
if ($UrunGuncellemeSayisi>0) {
header("Location:index?SK=94");
exit();
}else{
header("Location:index?SK=92");
exit();
}
} else {
$UrunEklemeSorgusu = $VeritabaniBaglantisi->prepare("INSERT INTO sepet (UyeId, UrunId, SepetNumarasi, VaryantId, UrunAdedi) values(?, ?, ?, ?, ?)");
$UrunEklemeSorgusu->execute([$KullaniciID, $GelenID, 1, $GelenVaryantID, 1]);
$UrunEklemeSayisi = $UrunEklemeSorgusu->rowCount();
$SonidDegeri = $VeritabaniBaglantisi->lastInsertId();
if ($UrunEklemeSayisi > 0) {
$SiparisNumarasiGuncellemeSorgusu = $VeritabaniBaglantisi->prepare("UPDATE sepet SET SepetNumarasi = ? WHERE UyeId = ? ");
$SiparisNumarasiGuncellemeSorgusu->execute([$SonidDegeri, $KullaniciID]);
$SiparisNumarasiGuncellemeSayisi = $SiparisNumarasiGuncellemeSorgusu->rowCount();
if ($SiparisNumarasiGuncellemeSayisi>0){
header("Location:index?SK=94");
exit();
}else{
header("Location:index?SK=92");
exit();
}
}
}
} else {
$UrunEklemeSorgusu = $VeritabaniBaglantisi->prepare("INSERT INTO sepet (UyeId, UrunId, VaryantId, UrunAdedi ) values(?, ?, ?, ?)");
$UrunEklemeSorgusu->execute([$KullaniciID, $GelenID, $GelenVaryantID, 1]);
$UrunEklemeSayisi = $UrunEklemeSorgusu->rowCount();
$SonidDegeri = $VeritabaniBaglantisi->lastInsertId();
if ($UrunEklemeSayisi > 0) {
$SiparisNumarasiGuncellemeSorgusu = $VeritabaniBaglantisi->prepare("UPDATE sepet SET SepetNumarasi = ? WHERE UyeId = ? ");
$SiparisNumarasiGuncellemeSorgusu->execute([$SonidDegeri, $KullaniciID]);
$SiparisNumarasiGuncellemeSayisi = $SiparisNumarasiGuncellemeSorgusu->rowCount();
if ($SiparisNumarasiGuncellemeSayisi>0){
header("Location:index?SK=94");
exit();
}else{
header("Location:index?SK=92");
exit();
}
}else{
header("Location:index?SK=92");
exit();
}
}
} else {
header("Location:index.php");
exit();
}
} else {
header("Location:index.php?SK=92");
exit();
}
?>