<?php
$link = mysqli_connect("localhost", "root", "", "news");
if ($link == false){
print("Ошибка: Невозможно подключиться к MySQL " . mysqli_connect_error());
}
else {
print("Соединение установлено успешно");
}
?>
<?php
$cookies_name = 'news';
setcookie($cookies_name, 0);
?>
<?php
if (isset($_COOKIE[$cookies_name]))
{
$sql = "SELECT COUNT(id) as count FROM news";
$result = mysqli_query($link, $sql);
while($row = mysqli_fetch_array($result)){
echo "<br />Новостей в базе: ".$row["count"]."<br />";
}
}
else {
$sql = "SELECT COUNT(id) as count FROM news";
$result = mysqli_query($link, $sql);
while($row = mysqli_fetch_array($result)){
echo "<br />Всего новостей в базе: ".$row["count"]."<br />";
}
}
?>
<form method="post" action="" enctype="multipart/form-data" >
<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
<input type="file" name="file[]" class="btn btn-sm btn-default fileinput-button" id="file-drop" multiple required></td><td>
<input type="submit" class="btn btn-primary" value="Загрузить" >
</form>