-
Notifications
You must be signed in to change notification settings - Fork 0
/
registrieren.php
316 lines (274 loc) · 14.4 KB
/
registrieren.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
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
<?php
session_start();
$pdo = new PDO('mysql:host=localhost;dbname=Users', 'root', '');
?>
<!DOCTYPE html>
<html>
<head>
<!-- Titel der Website -->
<title>Registrieren | Schuber Lampen</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Fontawesome CSS -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" integrity="sha384-5sAR7xN1Nv6T6+dT2mhtzEpVJvfS3NScPQTrOxhwjIuvcA67KV2R5Jz6kr4abQsz" crossorigin="anonymous">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="scss/bootstrap.css">
<!-- Bootstrap JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
<!-- My CSS -->
<link rel="stylesheet" href="css/style.css">
<!-- My Javascript -->
<script src="js/js.js"></script>
<!-- Favicon -->
<link rel="icon" href="Images/Logos/Schuber_Lampen_Logo_No_Text.png" type="image/x-icon"/>
</head>
<body>
<!-- Beginn Header-->
<?php
include("Header.php");
?>
<!-- Ende Header -->
<!-- Beginn Main -->
<!-- Beginn Slideshow -->
<div class="container-fluid main d-none d-lg-block">
<div id="myCarousel" class="carousel carousel-fade slide" data-ride="carousel" data-interval="2500">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" width="900" length="300" src="Images/Carousel/03_carousel.jpg">
</div>
<div class="carousel-item">
<img class="d-block w-100" width="900" length="300" src="Images/Carousel/01_carousel.jpg">
</div>
<div class="carousel-item">
<img class="d-block w-100" width="900" length="300" src="Images/Carousel/02_carousel.jpg">
</div>
</div>
</div>
<div class="covertext">
<div class="col-lg-10" style="float:none; margin:0 auto;">
<h1 class="title" >Registrierung</h1>
<h3 class="subtitle" style="text-shadow: 2px 2px 5px black">Werden Sie teil des besten Lampenhändler der Schweiz.</h3>
</div>
</div>
</div>
<!-- Ende Slideshow -->
<?php
$showFormular = true; //Variable ob das Registrierungsformular anezeigt werden soll
if(isset($_GET['register'])) {
$error = false;
$vorname = $_POST['vorname'];
$nachname = $_POST['nachname'];
$email = $_POST['email'];
$passwort = $_POST['passwort'];
$passwort2 = $_POST['passwort2'];
$strasse = $_POST['strasse'];
$hausnummer = $_POST['hausnummer'];
$ortschaft = $_POST['ortschaft'];
$plz = $_POST['plz'];
$geschlecht = $_POST['geschlecht'];
$geburtstag = $_POST['geburtstag'];
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
echo 'Bitte eine gültige E-Mail-Adresse eingeben<br>';
$error = true;
}
if(strlen($passwort) == 0) {
echo 'Bitte ein Passwort angeben<br>';
$error = true;
}
if($passwort != $passwort2) {
echo 'Die Passwörter müssen übereinstimmen<br>';
$error = true;
}
//Überprüfe, dass die E-Mail-Adresse noch nicht registriert wurde
if(!$error) {
$statement = $pdo->prepare("SELECT * FROM users WHERE email = :email");
$result = $statement->execute(array('email' => $email));
$user = $statement->fetch();
if($user !== false) {
echo 'Diese E-Mail-Adresse ist bereits vergeben<br>';
$error = true;
}
}
//Keine Fehler, wir können den Nutzer registrieren
if(!$error)
{
$passwort_hash = password_hash($passwort, PASSWORD_DEFAULT);
$statement = $pdo->prepare("INSERT INTO users (vorname, nachname, email, passwort, strasse, hausnummer, plz, ortschaft, geburtstag, geschlecht) VALUES (:vorname, :nachname, :email, :passwort, :strasse, :hausnummer, :plz, :ortschaft, :geburtstag, :geschlecht)");
$result = $statement->execute(array('vorname' => $vorname, 'nachname' => $nachname, 'email' => $email, 'passwort' => $passwort_hash, 'strasse' => $strasse, 'hausnummer' => $hausnummer, 'plz' => $plz, 'ortschaft' => $ortschaft, 'geburtstag' => $geburtstag, 'geschlecht' => $geschlecht));
if($result)
{
$pdocart = new PDO('mysql:host=localhost;dbname=Cart', 'root', '');
$pdocart->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$createtable = "CREATE TABLE `CART: ".$email."` (
id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Produktname VARCHAR(35),
Preis VARCHAR(5),
Anzahl int(35),
Total VARCHAR(5)
)";
$pdocart->exec($createtable);
echo "<script>
alert('Sie wurden erfolgreich registriert');
window.open('login.php');
</script>";
}
else
{
echo 'Beim Abspeichern ist leider ein Fehler aufgetreten<br>';
}
}
}
if($showFormular) {
?>
<br>
<center><div class="row featurette col-lg-7" style="margin-bottom: 30px">
<div class="col-md-12 mb-md-0 mb-5">
<form action="?register=1" method="post" name="Register-form">
<!-- Beginn Row -->
<div class="row">
<!-- Beginn Column -->
<div class="col-md-6">
<div class="md-form mb-0">
<label for="vorname">Vorname:</label>
<input type="text" size="40" maxlength="50" name="vorname" class="form-control">
</div>
</div>
<!-- Ende Column -->
<!-- Beginn Column -->
<div class="col-md-6">
<div class="md-form mb-0">
<label for="nachname">Nachname:</label>
<input type="text" size="40" maxlength="50" name="nachname" class="form-control">
</div>
</div>
<!-- Ende Column -->
</div>
<!-- Ende Row --><br>
<!-- Beginn Row -->
<div class="row">
<!-- Beginn Column -->
<div class="col-md-6">
<div class="md-form mb-0">
<label for="email">E-Mail:</label>
<input type="email" size="40" maxlength="50" name="email" class="form-control">
</div>
</div>
<!-- Ende Column -->
<!-- Beginn Column -->
<div class="col-md-5">
<div class="md-form mb-0">
<label for="strasse">Strasse:</label>
<input type="text" size="30" maxlength="20" name="strasse" class="form-control">
</div>
</div>
<div class="col-md-1">
<div class="md-form mb-0">
<label for="hausnummer">Nr:</label>
<input type="hausnummer" size="5" maxlength="10" name="hausnummer" class="form-control">
</div>
</div>
<!-- Ende Column -->
</div>
<!-- Ende Row --><br>
<!-- Beginn Row -->
<div class="row">
<!-- Beginn Column -->
<div class="col-md-6">
<div class="md-form mb-0">
<label for="ortschaft">Ortschaft:</label>
<input type="text" size="40" maxlength="20" name="ortschaft" class="form-control">
</div>
</div>
<!-- Ende Column -->
<!-- Beginn Column -->
<div class="col-md-2">
<div class="md-form mb-0">
<label for="plz">PLZ:</label>
<input type="text" size="40" maxlength="10" name="plz" class="form-control">
</div>
</div>
<!-- Ende Column -->
</div>
<!-- Ende Row --><br>
<!-- Beginn Row -->
<div class="row">
<!-- Beginn Column -->
<div class="col-md-6">
<div class="md-form mb-0">
<label for="passwort">Passwort:</label>
<input type="password" size="40" maxlength="50" name="passwort" class="form-control">
</div>
</div>
<!-- Ende Column -->
<!-- Beginn Column -->
<div class="col-md-6">
<div class="md-form mb-0">
<label for="passwort2">Passwort wiederholen:</label>
<input type="password" size="40" maxlength="50" name="passwort2" class="form-control">
</div>
</div>
<!-- Ende Column -->
</div>
<!-- Ende Row --><br>
<!-- Beginn Row -->
<div class="row">
<!-- Beginn Column -->
<div class="col-md-3">
<div class="md-form mb-0">
<label for="geburtstag">Geburtstag:</label>
<input type="date" name="geburtstag" class="form-control">
</div>
</div>
<!-- Ende Column -->
<!-- Beginn Column -->
<div class="col-md-3">
<br><br>
<div class="md-form mb-0">
<label for="männlich">Männlich:</label>
<input type="radio" name="geschlecht" class="form-label" id="männlich" value="männlich">
</div>
</div>
<!-- Ende Column -->
<!-- Beginn Column -->
<div class="col-md-3">
<br><br>
<div class="md-form mb-0">
<label for="weiblich">Weiblich:</label>
<input type="radio" name="geschlecht" class="form-label" id="weiblich" value="weiblich">
</div>
</div>
<!-- Ende Column -->
<!-- Beginn Column -->
<div class="col-md-3">
<br><br>
<div class="md-form mb-0">
<label for="sonstiges">Sonstiges:</label>
<input type="radio" name="geschlecht" class="form-label" id="sonstiges" value="sonstiges">
</div>
</div>
<!-- Ende Column -->
</div>
<!-- Ende Row --><br>
<div class="text-center text-md-left">
<input type="submit" class="btn btn-secondary" style="color: white" value="Registrieren">
</div>
</form>
</div>
</div></center>
<?php
} //Ende von if($showFormular)
?>
<!-- Ende Main -->
<!-- Beginn Footer -->
<?php include("Footer.php");?>
<!-- Ende Footer -->
</body>
</html>