forked from papullo/progetto_PW
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsClienti.php
More file actions
260 lines (131 loc) · 5 KB
/
insClienti.php
File metadata and controls
260 lines (131 loc) · 5 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
<?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">
<style type="text/css">@import "css/jquery.datepick.css";</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="javascript/jquery.datepick.js"></script>
<script type="text/javascript">
$(function() {
$('#popupDatepicker').datepick({dateFormat: 'yyyy-mm-dd'});
});
</script>
</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">Inserisci Cliente</p>
</div> <div id="content">
<div class="post"> <div style="clear: both;"> </div> <div class="entry">
<form name="inserimentoCli" action="?action=insCli" method="post">
Nome:<br />
<input type="text" name="nome" class="input" /> <br />
Cognome:<br />
<input type="text" name="cognome" class="input"> <br />
Data di Nascita:<br />
<input type="text" name="dataNascita" id="popupDatepicker"> <br />
Telefono:<br />
<input type="text" name="telefono" class="input"> <br />
Indirizzo:<br />
<input type="text" name="indirizzo" class="input"> <br />
<p class="links">
<input type="submit" value="Invio" class="form_btn" /> <br />
</p>
</form>
</div> </div> <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 -->
<?php
if ($_GET['action'] == "insCli" and isset($_SESSION['log']))
{
if (( $_POST['nome'] == "" ) || ( $_POST['cognome'] == "" ) || ( $_POST['dataNascita'] == "" ) || ( $_POST['indirizzo'] == "" ))
{
print("<script language='javascript'>alert('Compilare tutti i campi per continuare!');</script>");
print("<script language='javascript'>location.href='javascript:history.go(-1)';</script>");
exit;
}
$query = mysql_query("SELECT * FROM Cliente");
$data = mysql_fetch_array($query);
$righe = mysql_num_rows($query);
if($righe != 0)
{
if($data['cognome']==$_POST['cognome'] and $data['nome']==$_POST['nome'] and $data['data_nascita']==$_POST['dataNascita'] and $data['indirizzo']==$_POST['indirizzo'])
{
//errore
print("<script language='javascript'>alert('Il dipendente è già registrato!');</script>");
exit;
}
}
if($_POST['telefono']=="")
{
$query = "INSERT INTO Cliente (id_cliente,nome,cognome,data_nascita,telefono,indirizzo,password) VALUES (NULL,\"".$_POST['nome']."\",\"".$_POST['cognome']."\",\"".$_POST['dataNascita']."\",NULL,\"".$_POST['indirizzo']."\",NULL)";
}
else
{
$query = "INSERT INTO Cliente (id_cliente,nome,cognome,data_nascita,telefono,indirizzo,password) VALUES (NULL,\"".$_POST['nome']."\",\"".$_POST['cognome']."\",\"".$_POST['dataNascita']."\",\"".$_POST['telefono']."\",\"".$_POST['indirizzo']."\",NULL)";
}
mysql_query($query,$con);
mysql_close($con);
print("<script language='javascript'>alert('Registrazione avvenuta con successo');</script>");
print("<script language='javascript'>location.href='home.php';</script>");
}
?>
</center>
</body>
</html>