-
Notifications
You must be signed in to change notification settings - Fork 1
/
ekle.php
85 lines (76 loc) · 2.72 KB
/
ekle.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
<?php
include "header.php";
include "db.php";
function seo($s) {
$tr = array('ş','Ş','ı','I','İ','ğ','Ğ','ü','Ü','ö','Ö','Ç','ç','(',')','/',':',',','!','"',"#","$","%","&",'\'','*','+','.',';','<','>','=','?','@','[',']','^','`','{','}','|','~','_','’',"”",'‘'," ",'ä');
$eng = array('s','s','i','i','i','g','g','u','u','o','o','c','c','','','-','-','','','','','','','','','','','','','','','','','','','','','','','','','','',"","","","-","");
$s = str_replace($tr,$eng,$s);
$s = strtolower($s);
$s = preg_replace('/&amp;amp;amp;amp;amp;amp;amp;amp;.+?;/', '', $s);
$s = preg_replace('/\s+/', '-', $s);
$s = preg_replace('|-+|', '-', $s);
$s = preg_replace('/#/', '', $s);
$s = str_replace('.', '', $s);
$s = trim($s, '-');
return $s;
}
if ($_POST)
{
if ($_POST['baslik']=="" || $_POST['aciklama']=="")
{
$uyari="Lütfen boş alanları doldurunuz";
}
else
{
$baslik=htmlspecialchars($_POST["baslik"]);
$icerik=htmlspecialchars($_POST["aciklama"]);
$seflink=seo($baslik);
$sorgu=$baglan->prepare("insert into makaleler(baslik,aciklama,seflink) values(?,?,?)");
$sorgu->execute(array($baslik,$icerik,$seflink));
$hata=$sorgu->errorInfo();
if(empty($hata[2]))
{
$uyari="Kayıt İşlemi Başarılı";
}
else
{
$uyari="Kayıt İşlemi Başarısız:<br>".$hata[2];
}
}
}
?>
<div class="container">
<h1 class="text-center">Blog Yazısı Ekle</h1>
<form method="post" action="">
<div class="form-group">
<label for="exampleFormControlInput1">Başlık</label>
<input type="text" class="form-control" placeholder="Başlık" name="baslik">
</div>
<div class="form-group">
<label >Açıklama</label>
<textarea class="form-control" name="aciklama" rows="3"></textarea>
</div>
<div class="form-group text-right">
<button type="submit" class="btn btn-primary btnkaydet">Kaydet</button>
</div>
<div class="form-group uyari">
<?php if (isset($uyari)): ?>
<div class="alert alert-info">
<strong> <?php echo $uyari; ?></strong>
</div>
<?php endif; ?>
</div>
</form>
</div>
</body>
</html>
<script>
$(document).ready(function () {
<?php
if(isset($uyari) && $uyari=="Kayıt İşlemi Başarılı")
{
echo 'setTimeout(function () {$(".uyari").hide()}, 3000);';
}
?>
})
</script>