File: /home/sinanpasha/public_html/risale/yeni/sepetim.php
<?php
include ("include/uye-oturum.php");
// Sepete Ekle Butonuna basınca önce link ile gönderilen uye_id değişkenini $_GET ile çek ve aynı ürün aynı üyenin seppetinde varsa ve sipariş tarihi boşsa miktarı 1 artır. Yoksa sepete ekle.
$urun_id = $_GET ["urun_id"];
if( $urun_id>0) {
$sepet_tarihi = date ("d/m/Y");
$sepet_kontrol = mysql_query("select * from sepet where uye_id='$session_id' and urun_id='$urun_id' and siparis_tarihi=''");
$urun_say = mysql_num_rows($sepet_kontrol);
if ($urun_say==0) {
// Ürün Sepette olmadığı için ürünü sepete ekledi
mysql_query("insert into sepet set uye_id='$session_id', urun_id='$urun_id', miktar=1, sepet_tarihi='$sepet_tarihi' ");
} else {
// Ürün Sepette olduğu için miktarı 1 artırdı
$sepet_dizi = mysql_fetch_array($sepet_kontrol);
$miktar = $sepet_dizi ["miktar"];
$sepet_id = $sepet_dizi ["sepet_id"];
$miktar = $miktar + 1 ;
mysql_query("update sepet set miktar=$miktar where sepet_id='$sepet_id'");
}
header("location:sepetim.php");
}
?>
<!doctype html>
<html lang="tr">
<head>
<meta charset="utf-8">
<title>Bil Soft Eticaret - Anasayfa</title>
<meta name="language" content="tr">
<meta name="description" content=" ">
<meta name="author" content="Bil Shop Eticaret Sitesi">
<meta name="robots" content="index,follow">
<meta name="Copyright" content="Tüm hakları Bil Shop Firmasına aittir.">
<link rel="stylesheet" type="text/css" href="css/stiller.css">
<link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="icon" href="favicon.ico" type="image/x-icon">
<!-- Responsive için gerekli Head kodu başladı -->
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/stiller-responsive.css">
<link rel="stylesheet" href="js/responsive-menu/slicknav.css">
<script src="js/responsive-menu/modernizr.min.js"></script>
<!-- Responsive için gerekli Head kodu bitti -->
</head>
<body>
<!-- ==================== Header Top ==================== -->
<?php
include("include/header-top.php");
?>
<!-- ==================== Wrapper Top ==================== -->
<div id="wrapper" class="sablon_width">
<?php
include ("include/header.php");
?>
<div id="page_title">
<h1>SEPET - <?php echo $_SESSION["uye_ad_soyad"];?> </h1>
</div>
<div id="page_content">
<?php
// Üyeye ait sepeti listeleme başladı
// select * from sepet where uye_id=4 and siparis_tarihi=''
// Sepet ile Ürünler Tablosunun Join ile birleştirilmiş hali. İki tabloyu joinlemek için iki tabloda ortak bir sütun olmalı
//select sepet.sepet_id, sepet.miktar, urunler.resim, urunler.urun_adi, urunler.fiyat from sepet join urunler on sepet.urun_id=urunler.urun_id where uye_id=4 and siparis_tarihi=''
$sepet_listele = mysql_query("select sepet.sepet_id, sepet.miktar, urunler.resim, urunler.urun_adi, urunler.fiyat from sepet join urunler on sepet.urun_id=urunler.urun_id where uye_id='$session_id' and siparis_tarihi=''");
$urun_say = mysql_num_rows($sepet_listele);
if ($urun_say == 0 ) {
echo "Sepet boş";
} else {
?>
<form name="form1" method="post" action="">
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td height="25" align="center"><strong>SİL</strong></td>
<td height="25" align="center"><strong>RESİM</strong></td>
<td height="25" align="center"><strong>ÜRÜN ADI</strong></td>
<td height="25" align="center"><strong>MİKTAR</strong></td>
<td height="25" align="center"><strong>BİRİM FİYATI</strong></td>
<td height="25" align="center"><strong>TUTAR</strong></td>
</tr>
<?php
// Üyeye ait sepeti listeleme başladı
// select * from sepet where uye_id=4 and siparis_tarihi=''
// Sepet ile Ürünler Tablosunun Join ile birleştirilmiş hali. İki tabloyu joinlemek için iki tabloda ortak bir sütun olmalı
//select sepet.sepet_id, sepet.miktar, urunler.resim, urunler.urun_adi, urunler.fiyat from sepet join urunler on sepet.urun_id=urunler.urun_id where uye_id=4 and siparis_tarihi=''
while ($sepet_dizi = mysql_fetch_array($sepet_listele)) {
$sepet_id = $sepet_dizi ["sepet_id"];
$resim = $sepet_dizi ["resim"];
$urun_adi = $sepet_dizi ["urun_adi"];
$miktar = $sepet_dizi ["miktar"];
$fiyat = $sepet_dizi ["fiyat"];
?>
<tr>
<td height="23" align="center"><input name="sil_id[]" type="checkbox" id="sil_id[]" value="8"></td>
<td align="center"><img src="resimler/urun-resimleri/<?php echo $resim;?>" width="100" alt="<?php echo $urun_adi;?>"></td>
<td><?php echo $urun_adi;?></td>
<td align="center"><input name="miktar[8]" type="text" id="miktar[]" value="<?php echo $miktar;?>" size="2" maxlength="4"></td>
<td align="right"><?php echo number_format($fiyat,2,",",".");?> TL.</td>
<td align="right">
<?php
$tutar = $miktar * $fiyat;
echo number_format($tutar,2,",",".");
$satir_toplamlari = $satir_toplamlari + $tutar;
?>
TL.</td>
</tr>
<?php
}
// Üyeye ait sepeti listeleme başladı
?>
<tr>
<td height="23" colspan="5" align="right"><strong>
<label for="satir"></label>
KDV'SİZ TOPLAM </strong></td>
<td align="right"><strong><?php echo number_format($satir_toplamlari,2,",","."); ?> TL.</strong></td>
</tr>
<tr>
<td height="23" colspan="5" align="right"><strong>KDV </strong></td>
<td align="right"><strong>
<?php
$kdv = $satir_toplamlari * 0.18;
echo number_format($kdv,2,",",".");
?>
TL.</strong></td>
</tr>
<tr>
<td height="23" colspan="5" align="right"><strong> GENEL TOPLAM </strong></td>
<td align="right"><strong>
<?php
$genel_toplam = $kdv + $satir_toplamlari;
echo number_format($genel_toplam,2,",",".");
?>
TL.</strong></td>
</tr>
<tr align="right">
<td height="23" colspan="6" align="center"><input type="submit" name="button2" id="button2" value="Seçilenleri Sil">
<input type="submit" name="button3" id="button3" value="Sepeti Güncelle">
<input type="submit" name="button4" id="button4" value="Sipariş Ver"></td>
</tr>
</table>
</form>
<?php
}
?>
</div>
<?php
include("include/adres.php");
?>
</div>
<!-- ==================== Footer Bottom ==================== -->
<?php
include("include/footer.php");
?>
</body>
</html>