NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<?php
include("vb.php");
function turkce($metin) {
$metin = trim($metin);
$aranan= array('Ç','ç','Ğ','ğ','ı','İ','Ö','ö','Ş','ş','Ü','ü',' ');
$yerine = array('c','c','g','g','i','i','o','o','s','s','u','u','-');
return str_replace($aranan,$yerine,$metin);
}

function watermark_image($target, $wtrmrk_file, $newcopy) {
$watermark = imagecreatefrompng($wtrmrk_file);
imagealphablending($watermark, false);
imagesavealpha($watermark, true);
$img = imagecreatefromjpeg($target);
$img_w = imagesx($img);
$img_h = imagesy($img);
$wtrmrk_w = imagesx($watermark);
$wtrmrk_h = imagesy($watermark);
$dst_x = ($img_w / 2) - ($wtrmrk_w / 2);
$dst_y = ($img_h / 2) - ($wtrmrk_h / 2);
imagecopy($img, $watermark, $dst_x, $dst_y, 0, 0, $wtrmrk_w, $wtrmrk_h);
imagejpeg($img, $newcopy, 100);
imagedestroy($img);
imagedestroy($watermark);
}

?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Veritabanı İşlemleri</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>

<form action="" method="post" enctype="multipart/form-data">
<div class="col-md-4">
<table class="table">
<tr>
<td>Başlık</td>
<td><input type="text" name="baslik" class="form-control"></td>
</tr>

<tr>
<td>İçerik</td>
<td><textarea name="icerik" class="form-control"></textarea></td>
</tr>

<tr>
<td>Foto</td>
<td><input type="file" name="foto"></td>
</tr>

<tr>
<td></td>
<td><input type="submit" value="Ekle" class="btn btn-default"></td>
</tr>

</table>
</div>


</form>

<!-- Öncelikle HTML düzenimizi oluşturuyoruz. Daha sonra girdiğimiz verileri veritabanına eklemesi için PHP kodlarına geçiyoruz. -->

<?php

if ($_POST) { // Butona basılıp basılmadığını kontrol ediyoruz.

$baslik = $_POST['baslik']; // Sayfa yenilendikten sonra post edilen başlığı $baslik olarak tanımlıyoruz.
$icerik = $_POST['icerik'];

if ($baslik<>"" && $icerik<>"" && isset($_FILES["foto"])) { // Veri alanlarının boş olmadığını kontrol ettiriyoruz.
$hata = $_FILES["foto"]["error"];
if ($hata != 0)
{
echo "Hata " . $hata;
}
else
{
$boyut=$_FILES["foto"]["size"];
if ($boyut>(1024*1024*3))
{
echo "3 MB küçük foto ekleyin";
}
else
{
$tip=$_FILES["foto"]["type"];
$isim=$_FILES["foto"]["name"];
$uzanti=explode(".",$isim);
$uzanti=$uzanti[count($uzanti)-1];
if ($tip!="image/jpeg" || $uzanti!="jpg")
{
echo "Sadece JPG türü foto ekleyin";
}
else
{
$dosya=$_FILES["foto"]["tmp_name"];
$foto=rand(1000000000,10000000000).'-'.turkce($isim);
copy($dosya,"img/".$foto);
watermark_image('img/'.$foto,'img/logo.png', 'img/'.$foto);
if ($baglanti->query("INSERT INTO makale (baslik, icerik, foto) VALUES ('$baslik','$icerik', '$foto')"))
{
echo"Kayıt başarılı";
}
else
{
echo" Kayıt başarısız";
}
}
}
}

}

}

?>

<!-- ############################################################## -->

<!-- Veritabanına eklenmiş verileri sıralamak için önce üst kısmı hazırlayalım. -->
<div class="col-md-5">
<table class="table">

<tr>
<th>No</th>
<th>Foto</th>
<th>Başlık</th>
<th>İçerik</th>
<th></th>
<th></th>
</tr>

<!-- Şimdi ise verileri sıralayarak çekmek için PHP kodlamamıza geçiyoruz. -->

<?php

$sorgu = $baglanti->query("SELECT * FROM makale"); // Makale tablosundaki tüm verileri çekiyoruz.

while ($sonuc = $sorgu->fetch_assoc()) {

$id = $sonuc['id']; // Veritabanından çektiğimiz id satırını $id olarak tanımlıyoruz.
$baslik = $sonuc['baslik'];
$icerik = $sonuc['icerik'];
$foto = $sonuc['foto'];

// While döngüsü ile verileri sıralayacağız. Burada PHP tagını kapatarak tırnaklarla uğraşmadan tekrarlatabiliriz.
?>

<tr>
<td><?php echo $id; // Yukarıda tanıttığımız gibi alanları dolduruyoruz. ?></td>
<td><img src="img/<?php echo $foto; ?>" title="<?php echo $foto; ?>" alt="<?php echo $foto; ?>" width="100px"></td>
<td><?php echo $baslik; ?></td>
<td><?php echo $icerik; ?></td>
<td><a href="duzenle.php?id=<?php echo $id; ?>">Düzenle</a></td>
<td><a href="sil.php?id=<?php echo $id; ?>">Sil</a></td>
</tr>

<?php } // Tekrarlanacak kısım bittikten sonra PHP tagının içinde while döngüsünü köşeli parantezi kapatarak sonlandırıyoruz. ?>

</table>
</div>
</body>
</html>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.