-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathizmijeni-clanak.php
149 lines (126 loc) · 4.1 KB
/
izmijeni-clanak.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel=icon href=img/favicon.png sizes="64x64" type="image/png">
<meta http-equiv="Cache-control" content="no-cache">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300&display=swap" rel="stylesheet">
<link href="animate.css" type="text/css" rel="stylesheet" />
<link href="administracija.css" type="text/css" rel="stylesheet" />
<title>Le Monde | Izmijeni članak</title>
</head>
<?php
include_once("header.php");
?>
<div class="header-razmak">
</div>
<?php
$id = $_GET['id'];
include 'connect.php';
define('UPLPATH', 'slike-clanci/');
$query = "SELECT * FROM novosti WHERE id='$id'";
$result = mysqli_query($dbc, $query);
$clanak = mysqli_fetch_array($result);
echo '<article>
<div class="wrapper">
<div class="sekcije animated fadeIn">
<div class="sekcije-razmak">
<hr class="sekcije-hr">
</div>
<center>
<form enctype="multipart/form-data" action="" method="POST">
<div class="form-item">
<label for="title">Naslov vijesti</label>
<div class="form-field">
<input type="text" name="title" value="'.$clanak['naslov'].'">
</div>
</div>
<div>
<label for="about">Kratki sadržaj vijesti (do 150 znakova)</label>
<div class="form-field">
<textarea name="about" id="" cols="30" rows="10">'.$clanak['sazetak'].'</textarea>
</div>
</div>
<div class="form-item">
<label for="content">Sadržaj vijesti</label>
<div class="form-field">
<textarea name="content" id="" cols="30" rows="10">'.$clanak['tekst'].'</textarea>
</div>
</div>
<br>
<div class="form-item">
<label for="pphoto">Slika</label>
<div class="form-field">
<input type="file" accept="image/jpeg, image/gif" class="input-text" value="'.UPLPATH.$clanak['slika'].'" name="pphoto"/>
<br>
<img src="'.UPLPATH.$clanak['slika'].'" width=150px>
</div>
</div>
<br>
<div class="form-item">
<label for="category">Kategorija vijesti</label>
<div class="form-field">
<select name="category" id="" value="'.$clanak['kategorija'].'">
<option value="Sport">Sport</option>
<option value="Politika">Politika</option>
</select>
</div>
</div>
<br>
<div class="form-item">
<label>Spremiti u arhivu:
<div class="form-field">';
if($clanak['arhiva'] == 0){
echo '<input type="checkbox" name="archive" id="archive" value="1"/>';
}
else{
echo '<input type="checkbox" name="archive" id="archive" value="2" checked/>';
}
echo '</div>
</label>
</div>
<div class="form-item">
<input type="reset" value="Poništi" name="poništi">
<input type="submit" value="Prihvati" name="prihvati">
</div>
<br>
</form>
</center>
<div class="sekcije-razmak">
<hr class="sekcije-hr">
</div>
</div>
</div>
</article>';
?>
<footer>
<center>
<h4>Izrada:</h4>
<h4>Luka Rukavina </h4>
<p>lrukavina@tvz.hr</p>
</center>
</footer>
</body>
</html>
<?php
if(isset($_POST['prihvati'])){
$picture = $_FILES['pphoto']['name'];
$title = $_POST['title'];
$about = $_POST['about'];
$content = $_POST['content'];
$category = $_POST['category'];
$archive = $_POST['archive'];
$target_dir = 'slike-clanci/'.$picture;
if($picture != ""){
move_uploaded_file($_FILES['pphoto']['tmp_name'], $target_dir);
$query = "UPDATE novosti SET naslov='$title', sazetak='$about', tekst='$content',
slika='$picture', kategorija='$category', arhiva='$archive' WHERE id=$id";}
else{
$query = "UPDATE novosti SET naslov='$title', sazetak='$about', tekst='$content',
kategorija='$category', arhiva='$archive' WHERE id=$id";
}
$result = mysqli_query($dbc, $query);
echo "<script> location.href='administracija.php'; </script>";
exit;
}
?>