· 6 years ago · Apr 06, 2019, 06:38 PM
1<html>
2 <head>
3 <title>Projekt</title>
4 <style>
5 body{background-color: silver;}
6 #menu{
7 margin-left: 3%;
8 border-style: solid;
9 border-width: 1px;
10 width: 93%;
11 height: 50px;
12 background-color: #336633;
13 float:left;
14 border-right-width:3px;
15 }
16
17 #menu2{
18 width:14.03%;
19 height: 40px;
20 background-color: aquamarine;
21 float: left;
22 border-left-style: solid;
23 font-size: 30px;
24 text-align: center;
25 margin-top: 0.4%;
26 text-decoration: none;
27 letter-spacing: 3px;
28 filter: brightness(80%);
29 }
30
31 #menu2:hover
32 {
33 filter: brightness(100%);
34 }
35
36
37 a{color: black;}
38 a:link {text-decoration: none}
39 a:visited {text-decoration: none}
40 a:active {text-decoration: none}
41 a:hover {text-decoration: underline}
42
43 input{border-radius: 5px;}
44
45 .cont{
46 font-weight: bold;
47 font-size: 20px;
48 height: 300px;
49 width: 400px;
50 margin-left: auto;
51 margin-right: auto;
52 border-radius: 10px;
53 text-align: center;
54 background-image: url(form/hip-square/hip-square.png);
55 box-shadow: 6px 9px 21px -1px rgba(0,0,0,0.9);
56 }
57
58 h1{
59 color: blue;
60 font-size: 30px;
61 }
62
63 input[type=text]{
64 margin-left: auto;
65 width: 300px;
66 height: 30px;
67 padding: 10px;
68 font-size: 15px;
69 }
70
71 input[type=file]{
72
73 width: 300px;
74 height: 30px;
75 font-size: 15px;
76 }
77
78 input[type=submit]{
79 background: red;
80 width: 150px;
81 height: 30px;
82 font-size: 20px;
83 border:none;
84 color:white;
85 letter-spacing: 2px;
86 }
87
88 input[type=submit]:hover{
89 filter:brightness(150%);
90 }
91
92
93
94 </style>
95
96 </head>
97 <body>
98 <div id="menu">
99 <div id="menu2"><a href="dodaj.php">Dodaj</a>
100 </div>
101
102 <div id="menu2"><a href="wyswietl.php">Wyświetl</a>
103 </div>
104
105 <div id="menu2"><a href="usun.php">Usuń</a>
106 </div>
107
108 <div id="menu2"><a href="modyfikuj.php">Modyfikuj</a>
109 </div>
110
111 <div id="menu2"><a href="ocen.php">Oceń</a>
112 </div>
113
114 <div id="menu2"><a href="wyniki.php">Wyniki</a>
115 </div>
116
117 <div id="menu2"><a href="kontakt.html">Kontakt</a>
118 </div>
119 </div>
120
121<?php
122 include("connect.php");
123 include("dane_connect.php");
124 $connect = new mysqli($host, $login, $pass, $bname);
125
126
127 $connect -> query("SET CHARSET utf8");
128 $connect -> query('CREATE DATABASE IF NOT EXISTS 3tia');
129 $connect->select_db('3tia');
130
131 $stworz = "CREATE TABLE IF NOT EXISTS projekt(id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (id), nazwa varchar(100), obszar varchar(100), opis varchar(100), uwagi varchar(100), obraz varchar(1000), glosy INT, wartosc INT)";
132 $connect->query($stworz);
133
134
135 if(ISSET($_POST['id'])){
136 if($_POST['id']=='dodaj'){
137 $nazwa=$_POST['nazwaa'];
138 $obszar=$_POST['obszarr'];
139 $opis=$_POST['opiss'];
140 $uwagi=$_POST['uwagii'];
141
142
143 move_uploaded_file($_FILES['obrazek']['tmp_name'], "grafika/".$_FILES['obrazek']['name']);
144 $obrazS="grafika/".$_FILES['obrazek']['name'];
145 $zapytanie="INSERT INTO projekt SET nazwa='$nazwa',obszar='$obszar',opis='$opis',uwagi='$uwagi',obraz='$obrazS'";
146
147
148 $connect->query($zapytanie);
149
150 }
151
152 if($_POST['id']=='usunKrotke'){
153 $usunKrotke=$_POST['idKrotki'];
154 $zapytanieKrotka="DELETE FROM projekt WHERE id='$usunKrotke' LIMIT 1";
155 $connect->query($zapytanieKrotka);
156 }
157
158 if($_POST['id']=='modyfikuj'){
159 $idM=$_POST['idM'];
160 $zapytanieM="SELECT * FROM projekt WHERE id='$idM'";
161 $result=$connect->query($zapytanieM);
162
163 while($row = $result->fetch_object()){
164
165 echo<<<HTML
166 <div class="cont">
167 <h1>Modyfikuj projekt</h1>
168 <form action="index.php" method="POST" enctype="multipart/form-data">
169
170 Nazwa:
171 <input type="text" name="n_nazwa"
172 value='$row->nazwa'><br/>
173 Obszar:
174 <input type="text" name="n_obszar"
175 value='$row->obszar'><br/>
176 Opis:    
177 <input type="text" name="n_opis"
178 value='$row->opis'><br/>
179 Uwagi:
180 <input type="text" name="n_uwagi"
181 value='$row->uwagi'><br/>
182 Obraz: 
183 <input type="file" name="n_obrazek"> <br>
184 <input type="hidden" name="id" value="modyfikacja">
185 <input type="hidden" name="n_id" value="$row->id">
186 <input type="submit" value="Zmodyfikuj">
187
188 </form>
189 </div>
190HTML;
191
192 }
193 }
194
195 if($_POST['id']=='modyfikacja'){
196 $n_id=$_POST['n_id'];
197 $n_nazwa = $_POST['n_nazwa'];
198 $n_obszar = $_POST['n_obszar'];
199 $n_opis = $_POST['n_opis'];
200 $n_uwagi = $_POST['n_uwagi'];
201
202 move_uploaded_file($_FILES['n_obrazek']['tmp_name'], "grafika/".$_FILES['n_obrazek']['name']);
203 $obrazS="grafika/".$_FILES['n_obrazek']['name'];
204 $zapytanieModyfikacja="UPDATE projekt SET nazwa='$n_nazwa',obszar='$n_obszar',opis='$n_opis',uwagi='$n_uwagi',obraz='$obrazS' WHERE id='$n_id'";
205
206 $connect->query($zapytanieModyfikacja);
207 }
208
209 if($_POST['id']=='glosuj'){
210 $glos=$_POST['glosowanie'];
211 $wartosc=$_POST['estymowanaW'];
212 $zapytanieW="UPDATE projekt SET glosy=glosy+1, wartosc=(wartosc+$wartosc)/glosy WHERE id='$glos'";
213 $connect->query($zapytanieW);
214 echo<<<AA
215 <b><p style="font-size:20px">Pomyślnie dodano kwotę wybranego projektu! Dziękujemy za oddanie głosu!</b><p>
216AA;
217 }
218
219
220 }
221
222 disconnect($connect);
223
224?>
225
226
227
228 </body>
229</html>