-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskripta.php
63 lines (51 loc) · 1.96 KB
/
skripta.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
<!DOCTYPE html>
<html>
<head>
<title>Article</title>
<meta charset="UTF-8" />
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<nav>
<ul>
<li><a href="index.php">HOME</a></li>
<li><a href="kategorija.php?id=sport">SPORT</a></li>
<li><a href="kategorija.php?id=kultura">KULTURA</a></li>
<li><a href="administracija.php">ADMINISTRACIJA</a></li>
</ul>
</nav>
<main>
<?php
session_start();
$dbc = mysqli_connect('localhost','root','','vijesti') or
die("Connection failed: ". mysqli_connect_error());
if(isset($_POST["send"])){
$naslov = $_POST["naslov"];
$sazetak = $_POST["sazetak"];
$clanak = $_POST["clanak"];
$kategorija = $_POST["kategorija"];
$slika = $_FILES["slika"]["name"];
if(isset($_POST["arhiva"])){
$arhiva = 1;
}else $arhiva = 0;
}
$datum = date("d M Y");
$query = "INSERT INTO clanak(naslov,sazetak,sadrzaj,kategorija,arhiva,datum,slika)
VALUES('$naslov', '$sazetak','$clanak','$kategorija','$arhiva','$datum','$slika')";
$result = mysqli_query($dbc,$query) or
die("Error querying database");
$target = 'img/'.$slika;
move_uploaded_file($_FILES["slika"]["tmp_name"], $target);
echo"<h1>" . $naslov . "</h1>";
echo "<p class = 'date'>" . date('d M Y') . "</p>";
echo "<img class = 'title-img' alt='Title image' src='" .$target. "'>";
echo "<h3>" . $sazetak . "</h3>";
echo "<p>" . $clanak . "</p>";
mysqli_close($dbc);
?>
</main>
<footer>
<p>Marin Jurišić, [email protected], 2020.</p>
</footer>
</body>
</html>