forked from papullo/progetto_PW
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodLibri.php
More file actions
452 lines (229 loc) · 10 KB
/
modLibri.php
File metadata and controls
452 lines (229 loc) · 10 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
session_start();
include("connettiDb.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>YourLibrary</title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="screen">
</head>
<body>
<div id="wrapper">
<div id="header" class="container">
<div id="logo">
<h1>Benvenuto in Yourlibrary</h1>
</div>
<?php
if(isset($_SESSION['log']))
{
echo
<div id=\"menu\">
<ul>
<li class=\"current_page_item\"><a href=\"home.php\">Home</a></li>
<li><a href=\"logout.php\">logout</a></li>
</ul>
</div>
</div><!-- end #header -->";
}
else
{
echo
<div id=\"menu\">
<ul>
<li class=\"current_page_item\"><a href=\"index.php\">Devi identificarti per accedere al sito</a></li>
</ul>
</div>
";
exit;
}
?>
<div id="page" class="container">
<div id="marketing">
<p class="text1">Modifica Editore/Autore/Genere</p>
</div> <div id="content">
<div class="post"> <div style="clear: both;"> </div> <div class="entry">
<form name="scegliMod" action="?action=modifica" method="post">
<select name="selMod" onchange="aut(this)">
<option value="" selected="selected">-- seleziona --</option>
<option value="editore">casa editrice</option>
<option value="autore">autore</option>
<option value="genere">genere</option>
</select>
<p class="links">
<input type="submit" value="Invio" class="form_btn" /> <br />
</p>
</form>
</div> </div>
<?php
if(isset($_SESSION['log']))
{
if($_GET['action']=="modifica")
{
echo"<div class=\"post\">
<h2 class=\"title\">Scegli chi vuoi modificare dall'elenco:</h2> <div style=\"clear: both;\"> </div> <div class=\"entry\">";
if($_POST['selMod']=="editore")
{
echo "<form action=?action=modEditore method=\"post\">";
echo "<select name=\"editore\">";
echo "<option value=\"\" selected=\"selected\">-- seleziona --</option>";
$query = "SELECT * FROM Casa_Editrice ORDER BY rag_sociale";
$result = mysql_query($query);
while ( $row = mysql_fetch_array($result,MYSQL_BOTH))
echo "<option value=".$row[0].">".$row[1]."</option>";
echo "</select>";
echo "<p class=\"links\"><input type=\"submit\" value=\"Invio\" class=\"form_btn\" /></p>";
echo "</form>";
}
if($_POST['selMod']=="autore")
{
echo "<br /><br />Seleziona quale Autore modificare<br /><br />";
echo "<form action=?action=modAutore method=\"post\">";
echo "<select name=\"autore\">";
echo "<option value=\"\" selected=\"selected\">-- seleziona --</option>";
$query = "SELECT * FROM Autore ORDER BY cognome";
$result = mysql_query($query);
while ( $row = mysql_fetch_array($result,MYSQL_BOTH))
echo "<option value=".$row[0].">".$row[1].$row[2]."</option>";
echo "</select>";
echo "<p class=\"links\"><input type=\"submit\" value=\"Invio\" class=\"form_btn\" /></p>";
echo "</form>";
}
if($_POST['selMod']=="genere")
{
echo "<br /><br />Seleziona quale Genere modificare<br /><br />";
echo "<form action=?action=modGenere method=\"post\">";
echo "<select name=\"genere\">";
echo "<option value=\"\" selected=\"selected\">-- seleziona --</option>";
$query = "SELECT * FROM Categoria ORDER BY genere";
$result = mysql_query($query);
while ( $row = mysql_fetch_array($result,MYSQL_BOTH))
echo "<option value=".$row[0].">".$row[1]."</option>";
echo "</select>";
echo "<p class=\"links\"><input type=\"submit\" value=\"Invio\" class=\"form_btn\" /></p>";
echo "</form>";
}
echo "</div>
</div>";
}
if($_GET['action']=="modEditore")
{
echo"<div class=\"post\"> <div style=\"clear: both;\"> </div> <div class=\"entry\">";
$editore=$_POST['editore'];
$query=mysql_query("SELECT * FROM Casa_Editrice WHERE id_editrice='$editore'");
$data = mysql_fetch_array($query);
echo "<form action=?action=updateEditore method=\"post\">";
echo "Ragione Sociale: <br />";
echo "<input type=\"input\" name=\"ragSociale\" value=\"".$data['rag_sociale']."\"/><br />";
echo "Numero di telefono: <br />";
echo "<input type=\"input\" name=\"numeroT\" value=\"".$data['numero_telefono']."\"/><br />";
echo "Email: <br />";
echo "<input type=\"input\" name=\"mail\" value=\"".$data['mail']."\"/><br />";
echo "<input type=\"hidden\" name=\"idEditore\" value=\"".$editore."\" class=\"input\" /><br />";
echo "<p class=\"links\"><input type=\"submit\" value=\"Invio\" class=\"form_btn\" /></p>";
echo "</form>";
echo "</div>
</div>";
}
if($_GET['action']=="modAutore")
{
echo"<div class=\"post\"> <div style=\"clear: both;\"> </div> <div class=\"entry\">";
$autore=$_POST['autore'];
$query=mysql_query("SELECT * FROM Autore WHERE id_autore='$autore'");
$data = mysql_fetch_array($query);
echo "<form action=?action=updateAutore method=\"post\">";
echo "Nome: <br />";
echo "<input type=\"input\" name=\"nome\" value=\"".$data['nome']."\"/><br />";
echo "Cognome: <br />";
echo "<input type=\"input\" name=\"cognome\" value=\"".$data['cognome']."\"/><br />";
echo "Anno di nascita: <br />";
echo "<input type=\"input\" name=\"annoN\" value=\"".$data['anno_nascita']."\"/><br />";
echo "Nazionalità: <br />";
echo "<input type=\"input\" name=\"nazio\" value=\"".$data['nazionalita']."\"/><br />";
echo "<input type=\"hidden\" name=\"idAutore\" value=\"".$autore."\" class=\"input\" /><br />";
echo "<p class=\"links\"><input type=\"submit\" value=\"Invio\" class=\"form_btn\" /></p>";
echo "</form>";
echo "</div>
</div>";
}
if($_GET['action']=="modGenere")
{
echo"<div class=\"post\"> <div style=\"clear: both;\"> </div> <div class=\"entry\">";
$genere=$_POST['genere'];
$query=mysql_query("SELECT * FROM Categoria WHERE id_categoria='$genere'");
$data = mysql_fetch_array($query);
echo "<form action=?action=updateGenere method=\"post\">";
echo "Genere: <br />";
echo "<input type=\"input\" name=\"gen\" value=\"".$data['genere']."\"/><br />";
echo "<input type=\"hidden\" name=\"idGenere\" value=\"".$genere."\" class=\"input\" /><br />";
echo "<p class=\"links\"><input type=\"submit\" value=\"Invio\" class=\"form_btn\" /></p>";
echo "</form>";
echo "</div>
</div>";
}
if($_GET['action']=="updateEditore")
{
$id=$_POST['idEditore'];
$ragSoc=$_POST['ragSociale'];
$numero=$_POST['numeroT'];
$mail=$_POST['mail'];
$query=mysql_query("UPDATE Casa_Editrice SET rag_sociale='$ragSoc',numero_telefono='$numero',mail='$mail' WHERE id_editrice='$id'");
print("<script language='javascript'>alert('modifica effettuata!');</script>");
print("<script language='javascript'>location.href='home.php';</script>");
}
if($_GET['action']=="updateAutore")
{
$id=$_POST['idAutore'];
$nome=$_POST['nome'];
$cognome=$_POST['cognome'];
$annoN=$_POST['annoN'];
$nazio=$_POST['nazio'];
$query=mysql_query("UPDATE Autore SET nome='$nome',cognome='$cognome',anno_nascita='$annoN',nazionalita='$nazio' WHERE id_autore='$id'");
print("<script language='javascript'>alert('modifica effettuata!');</script>");
print("<script language='javascript'>location.href='home.php';</script>");
}
if($_GET['action']=="updateGenere")
{
$id=$_POST['idGenere'];
$genere=$_POST['gen'];
$query=mysql_query("UPDATE Categoria SET genere='$genere' WHERE id_categoria='$id'");
print("<script language='javascript'>alert('modifica effettuata!');</script>");
print("<script language='javascript'>location.href='home.php';</script>");
}
}
?>
</center>
<div style="clear: both;"> </div> </div>
<!-- end #content --> <div style="clear: both;"> </div>
</div>
<!-- end #page -->
</div>
<!-- end #wrapper -->
<div id="footer-content" class="container">
<div id="footer-bg"> <div id="column2">
<p>Mattia Pavoni 73535<br />Pietro Carè 72610</p> </div> </div>
</div>
<div id="footer">
<p>Progetto Basi di Dati 2010/11</p>
</div>
<!-- end #footer -->
</body>
</html>