Я вот когда перезагружаю страницу мне добавляется еще один комментарий и так далее вот код, даже сделал проверку на пустоту, смотрите код:
<?php
session_start();
include "../config.php";
$id = $_GET['plugin'];
$sql = mysql_query("SELECT * FROM `db_articles` WHERE id='$id'");
$articles = mysql_fetch_array($sql);
function onPluginTop($title) {
include "../html/header.php";
}
function onPluginBottom() {
include "../html/footer.php";
}
onPluginTop($articles['title']);
$sql = mysql_query("SELECT * FROM `db_design`");
$design = mysql_fetch_array($sql);
$count_views = $articles['count_views'];
$count_views++;
$views = mysql_query("UPDATE `db_articles` SET count_views='$count_views' WHERE id='$id'");
if (isset($_POST['download'])) {
$count_downloads = $articles['count_downloads'];
$count_downloads++;
$download = mysql_query("UPDATE `db_articles` SET count_downloads='$count_downloads' WHERE id='$id'");
}
function smile($var) {
$symbol = array(
':-p',
'> (');
$graph = array(
'<img class="sm" style="width: 20px;margin: -5px 3px;opacity: 1;" src="../images/smiles/-C50gSvaIrM.jpg">',
'<img class="sm" style="width: 20px;margin: -5px 3px;opacity: 1;" src="../images/smiles/-KLTcaKM7G0.jpg">');
return str_replace($symbol, $graph, $var);
}
if (isset($_POST['submit-comment'])) {
if (empty($_POST['username'])) {
$username = 'Это поле должно быть заполненым';
}else{
if (empty($_POST['surname'])) {
$surname = 'Это поле должно быть заполненым';
}else{
if (empty($_POST['comment'])) {
$comment = 'Это поле должно быть заполненым';
}else{
$date = date('d.m.y в H:i');
$sql = mysql_query("INSERT INTO `db_comments` (`id_article`,`username`,`surname`,`comment`,`date`,`ip`) VALUES ('$id','".$_POST['username']."','".$_POST['surname']."','".$_POST['comment']."','$date','".$_SERVER['REMOTE_ADDR']."')");
}
}
}
}
?>
<?php
if ($id != $articles['id']) {
exit('Страница 404');
}
?>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<header>
<div class="mcpe-header">
<div class="mcpe-container">
<div class="mcpe-logo">
<a href="">MCPEPLUG</a>
<div class="mcpe-vk">
<a href="<?=$design['vk']?>"><i class="fab fa-vk"></i></a>
</div>
</div>
</div>
</div>
</header>
<div class="mcpe-image-article">
<img src="<?=$articles['image']?>" width="100%;" height="400px;" alt="">
</div>
<div class="mcpe-content-text-article">
<h3><?=$articles['title']?></h3>
<p><?=$articles['article']?></p>
<div class="btn-article">
<a href="<?=$articles['image']?>" class="btn-download" download>Скачать</a>
</div>
</div>
<?php
$sql = mysql_query("SELECT COUNT(id) FROM `db_comments` WHERE id_article='$id'");
$count = mysql_fetch_array($sql, MYSQL_NUM);
?>
<div class="mcpe-container">
<div class="mcpe-comments">
<h3 class="comments-count">Комментарии <span><?=$count[0]?></span></h3>
<?php
$sql = mysql_query("SELECT * FROM `db_comments` WHERE id_article='$id'");
while($comments = mysql_fetch_array($sql)) {?>
<div class="user-comments">
<span class="username"><?=$comments['username']?> <?=$comments['surname']?></span>
<time class="time"><?=$comments['date']?></time>
<div class="comment-message"><?=smile($comments['comment'])?></div>
</div>
<?php } ?>
<?php
$sql = mysql_query("SELECT * FROM `db_comments` WHERE ip='".$_SERVER['REMOTE_ADDR']."'");
$banned = mysql_fetch_array($sql);
if($banned['ban'] == 1) {
?>
<div class="mcpe-banned-comment">
<div class="mcpe-banned-title">Вы были заблокированы на добавление комментариев.<br> Следующий раз вы будите забанены на сайте</div><br>
<div class="mcpe-report">Причина: <?=$banned['cause']?></div>
</div>
<?php }else{
if ($banned['ban'] == 0) { ?>
<form action="" method="post">
<div class="form-group">
<input type="text" name="username" placeholder="Ваше имя" class="form-control">
</div>
<div class="mcpe-error"><?=$username?></div>
<div class="form-group">
<input type="text" name="surname" placeholder="Фамилия" class="form-control">
</div>
<div class="mcpe-error"><?=$surname?></div>
<div class="smile-form">
<div class="smiles">
<div class="title-smile">Часто используемые</div>
<div class="smile-image">
<span>
<img class="sm" src="../images/smiles/-C50gSvaIrM.jpg" alt=":-p">
</span>
<span>
<img class="sm" src="../images/smiles/-KLTcaKM7G0.jpg" alt="> (">
</span>
<span>
<img class="sm" src="../images/smiles/-nYCNRH7XlI.jpg" alt=":|">
</span>
<span>
<img class="sm" src="../images/smiles/0ag_haa_roQ.jpg" alt=":X">
</span>
<span>
<img class="sm" src="../images/smiles/1tjWx7_qjPg.jpg" alt="0;">
</span>
<span>
<img src="../images/smiles/2tGoywAqoxI.jpg" alt=")." class="sm">
</span>
<span>
<img src="../images/smiles/4JFV-YAh6PM.jpg" alt="3(" class="sm">
</span>
<span>
<img src="../images/smiles/7QM8oe4Kaxc.jpg" alt=":)love" class="sm">
</span>
<span>
<img src="../images/smiles/8vB_nWokHvI.jpg" alt="8-)" class="sm">
</span>
<span>
<img src="../images/smiles/a1vT56x2GNs.jpg" alt=":o" class="sm">
</span>
<span>
<img src="../images/smiles/a8aXhP3Uc8Q.jpg" alt=";-P" class="sm">
</span>
<span>
<img src="../images/smiles/aBGNNIkkKj8.jpg" alt=";o" class="sm">
</span>
<span>
<img src="../images/smiles/adore.png" alt="" class="sm">
</span>
<span>
<img src="../images/smiles/afterboom.png" alt="" class="sm">
</span>
<span>
<img src="../images/smiles/amazed.png" alt="" class="sm">
</span>
</div>
</div>
</div>
<div class="form-group">
<textarea name="comment" placeholder="Ваш коментарий" id="comment"></textarea>
</div>
<div class="smile">
<span><img class="open-smile" src="../images/smile_icon.png" alt=""></span>
</div>
<div class="mcpe-error"><?=$comment?></div>
<input type="submit" name="submit-comment" value="Отправить" class="mcpe-submit-comment">
</form>
<?php } } ?>
</div>
</div>
<?php
onPluginBottom();
?>