-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_user.php
More file actions
143 lines (139 loc) · 5.4 KB
/
Copy pathadd_user.php
File metadata and controls
143 lines (139 loc) · 5.4 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
<?php
require('dbconfig.php');
if(!$dbfun->is_logged_in()){ header('Location: login.php'); }
if(isset($_POST['btn-addUser'])){
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password = $_POST['repassword'];
$isadmin = $_POST['isadmin'];
$stmt= $db->prepare("SELECT email FROM users WHERE email = :email");
$stmt->bindParam(':email', $email);
$stmt->execute();
if($stmt->rowCount() > 0)
{
$msg = "<div class='alert alert-info'>
Użytkownik o podanym adresie już istnieje!
</div>";
}
else
{
if($dbfun->addUser($firstname, $lastname, $email, $password, $isadmin))
{
$msg = "<div class='alert alert-info'>
Użytkownik został dodany <strong><a href='users.php'>Wróć</a></strong>
</div>";
}
else
{
$msg = "<div class='alert alert-warning'>
<strong>SORRY!</strong> ERROR
</div>";
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="pl">
<head>
<meta charset="utf-8">
<title>Drawing Tasks System</title>
<meta name="Marek Kozłowski">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.validate.min.js"></script>
<script>
$(document).ready(function(){
$('#add_user-form').validate({
rules: {
firstname: {required: true},
lastname: {required: true},
email: {required: true, email: true},
password: {required: true, minlength: 5},
repassword: {required: true, minlength: 5, equalTo: '#password'}
},
messages: {
firstname: {required: 'Musisz podać imię'},
lastname: {required: 'Musisz podać nazwisko'},
email: {required: 'Musisz podać adres', email: 'Musisz podać poprawny adres'},
password: {required: 'Musisz podać hasło', minlength: 'Hasło musi zawierać min 5 znaków'},
repassword: {required: 'Musisz powtórzyć hasło', minlength: 'Hasło musi zawierać min 5 znaków', equalTo: 'Hasła muszą być identyczne'}
},
errorElement: 'div',
errorLabelContainer: '.errorTxt'
});
});
</script>
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<style type="text/css">
body { background: url(assets/bglight.png);}
.hero-unit { background-color: #fff; }
.center { display: block; margin: 0 auto; }
.navbar-fixed-bottom {background-color: #f5f5f5; }
</style>
</head>
<body>
<?php
if($dbfun->isadmin($_SESSION['key']) == 1){
include_once("ui/logged_navtop_admin.htm");
}else {
include_once("ui/logged_navtop.htm");
}
?>
<div class="container hero-unit">
<?php
if(isset($msg))
{
echo $msg;
}
?>
<form id="add_user-form" role="form" method="post">
<table class='table table-bordered'>
<tr>
<td>Imię</td>
<td><input type='text' name='firstname' class='form-control'></td>
</tr>
<tr>
<td>Nazwisko</td>
<td><input type='text' name='lastname' class='form-control'></td>
</tr>
<tr>
<td>Email</td>
<td><input type='text' name='email' class='form-control'></td>
</tr>
<tr>
<td>Hasło</td>
<td><input type='password' name='password' id='password' class='form-control'><td>
</tr>
<tr>
<td>Powtórz hasło</td>
<td><input type='password' name='repassword' class='form-control'><td>
</tr>
<tr>
<td>Admin</td>
<td>
<div class="btn-group" data-toggle="buttons" id="isadmin_radio">
<label class="btn btn-primary active">
<input type="radio" name="isadmin" id="option1" autocomplete="off" value="1"> Tak
</label>
<label class="btn btn-primary">
<input type="radio" name="isadmin" id="option2" autocomplete="off" value="0" checked> Nie
</label>
</div>
</td>
</tr>
<tr>
<td colspan="2">
<button type="submit" class="btn btn-primary" name="btn-addUser">
<span class="glyphicon glyphicon-edit"></span>Dodaj
</button>
<a href="users.php" class="btn btn-success"><i class="glyphicon glyphicon-backward"></i>Innym razem</a>
</td>
</tr>
</table>
<div class="errorTxt"></div>
</form>
</div>
<?php include("ui/footer.htm"); ?>
</body>
</html>