KOD :
<html>
<head>
<title> Alışveriş Listesi </title>
</head>
<body>
<?php
define("HOST", "mysql:host=localhost;dbname=SANSÜR");
define("KULLANICI", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ");
define("SİFRE", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ");
try {
$db = new PDO(HOST, KULLANICI, SİFRE);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->exec("SET names utf8");
}
catch (PDOException $ex) {
echo "Hata : ".$ex->getMessage();
}
?>
<table>
<thead>
<th>
Alınacak Ürün
</th>
<th>
   
</th>
<th>
Alındı Mı?
</th>
<th>
İşlemler
</th>
</thead>
<tbody>
<?php
if (isset($_POST['alındı'])) {
$id = trim(filter_input(INPUT_POST, 'id', FILTER_SANITIZE_STRING));
try {
$baglanti = new PDO("mysql:host=localhost;dbname=[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ");
$baglanti->exec("SET NAMES utf8");
$baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sorgu = $baglanti->prepare("UPDATE liste SET alındı_mı = 1 WHERE id='".$id."'");
$sorgu->bindParam(1, $id, PDO::PARAM_STR);
$sorgu->execute();
echo "<script> alert(' Başarılı ! '); </script>";
} catch (PDOException $e) {
die($e->getMessage());
}
$baglanti = null;
}
?>
<?php
if (isset($_POST['alınmadı'])) {
$id2 = trim(filter_input(INPUT_POST, 'id2', FILTER_SANITIZE_STRING));
try {
$baglanti = new PDO("mysql:host=localhost;dbname=[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ");
$baglanti->exec("SET NAMES utf8");
$baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sorgu = $baglanti->prepare("UPDATE liste SET alındı_mı = 0 WHERE id='".$id2."'");
$sorgu->bindParam(1, $id, PDO::PARAM_STR);
$sorgu->execute();
echo "<script> alert(' Başarılı ! '); </script>";
} catch (PDOException $e) {
die($e->getMessage());
}
$baglanti = null;
}
?>
<?php
if (isset($_POST['ekle'])) {
$alınacaklar = trim(filter_input(INPUT_POST, 'alınacaklar', FILTER_SANITIZE_STRING));
$alındı_mı = "0";
try {
$baglanti = new PDO("mysql:host=localhost;dbname=[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ");
$baglanti->exec("SET NAMES utf8");
$baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sorgu = $baglanti->prepare("INSERT INTO liste(alınacaklar, alındı_mı) VALUES(?, ?)");
$sorgu->bindParam(1, $alınacaklar, PDO::PARAM_STR);
$sorgu->bindParam(2, $alındı_mı, PDO::PARAM_STR);
$sorgu->execute();
echo "<script> alert(' Başarılı ! '); </script>";
} catch (PDOException $e) {
die($e->getMessage());
}
$baglanti = null;
}
?>
<?php
if (isset($_POST['sil'])) {
$id = trim(filter_input(INPUT_POST, 'silinecekler', FILTER_SANITIZE_STRING));
try {
$baglanti = new PDO("mysql:host=localhost;dbname=[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ");
$baglanti->exec("SET NAMES utf8");
$baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sorgu = $baglanti->prepare("DELETE FROM liste WHERE id = ".$id."");
$sorgu->bindParam(1, $alınacaklar, PDO::PARAM_STR);
$sorgu->execute();
echo "<script> alert(' Başarılı ! '); </script>";
} catch (PDOException $e) {
die($e->getMessage());
}
$baglanti = null;
}
?>
<?php
if (isset($_POST['degistir'])) {
$urunadi = trim(filter_input(INPUT_POST, 'urunadi', FILTER_SANITIZE_STRING));
$id3 = trim(filter_input(INPUT_POST, 'id3', FILTER_SANITIZE_STRING));
try {
$baglanti = new PDO("mysql:host=localhost;dbname=[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ", "[COLOR=#000000][FONT=Open Sans][SIZE=2]SANSÜR[/SIZE][/FONT][/COLOR] ");
$baglanti->exec("SET NAMES utf8");
$baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sorgu = $baglanti->prepare("UPDATE liste SET alınacaklar='".$urunadi."' WHERE id='".$id3."'");
$sorgu->bindParam(1, $urunadi, PDO::PARAM_STR);
$sorgu->bindParam(2, $id3, PDO::PARAM_STR);
$sorgu->execute();
echo "<script> alert(' Başarılı ! '); </script>";
} catch (PDOException $e) {
die($e->getMessage());
}
$baglanti = null;
}
?>
<?php
$db->exec("SET names utf8");
$sorgu = "SELECT * FROM liste WHERE alındı_mı = '0' ORDER BY id";
$islem = $db->prepare($sorgu);
$islem->execute(array('id' => $id));
while($veri = $islem->fetch()){
$id = $veri['id'];
$alınacaklar = $veri['alınacaklar'];
$alındı_mı = $veri['alındı_mı'];
?>
<tr>
<td>
<?php echo $alınacaklar; ?>(<?php echo $id; ?>)
</td>
<th>
   
</th>
<td>
<?php if ($alındı_mı == "1") { echo 'Evet'; } else { echo 'Hayır'; }?>
</td>
<td>
<?php echo ' <form action="" method="post"> <input type="hidden" id="id" name="id" value="'.$id.'"> <button type="submit" name="alındı">Alındı Olarak İşaretle</button> </form> ' ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<br /><br /><br /><br />
<table>
<tr>
<th>
<b>Yeni Ürün Ekle : </b>
<form action="" method="post">
<input type="text" id="alınacaklar" name="alınacaklar" placeholder="Ürün Adı">
<button type="submit" name="ekle">Ekle</button>
</form>
</th>
<th> </th><th> </th><th> </th><th> </th>
<th> </th><th> </th><th> </th><th> </th>
<th>
<b>Ürün ID İle Ürün Sil : </b>
<form action="" method="post">
<input type="text" id="silinecekler" name="silinecekler" placeholder="Ürün ID">
<button type="submit" name="sil">Sil</button>
</form>
</th>
</tr>
</table>
<b>Ürün ID İle Ürün Adı Değiştir : </b>
<form action="" method="post">
<input type="text" id="id3" name="id3" placeholder="Ürün ID">
<input type="text" id="urunadi" name="urunadi" placeholder="Yeni Ürün Adı">
<button type="submit" name="degistir">Değiştir</button>
</form>
<br /><br /><br /><br />
<b>Alınanlar :</b>
<?php
$db->exec("SET names utf8");
$sorgu = "SELECT * FROM liste WHERE alındı_mı = '1' ORDER BY id";
$islem = $db->prepare($sorgu);
$islem->execute(array('id' => $id));
while($veri = $islem->fetch()){
$id2 = $veri['id'];
$alınacaklar2 = $veri['alınacaklar'];
$alındı_mı2 = $veri['alındı_mı'];
?>
<?php echo $alınacaklar2; ?> (<?php echo $id2; ?>)
<?php echo ' <form action="" method="post"> <input type="hidden" id="id2" name="id2" value="'.$id2.'"> <button type="submit" name="alınmadı">Alınmadı Olarak İşaretle</button> </form> ' ?>
<?php } ?>
</body>
