-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
817 lines (407 loc) · 20.2 KB
/
register.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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<?php
$sms='';
$sweetout=false;
include('config.php');
$register_page=false;
$plicht3=false;
$plicht4=false;
if(isset($you_logged_in) AND $you_logged_in==true){
}else{
if($captcha_aktiv=='true'){
if(isset($_POST['captcha_code'])){
if ($_POST['captcha_code'] == $_SESSION['captcha_spam']) {
$plicht3=true;
} else {
$sms.=$language['register_wrong_capacha'].'<br>';
$plicht3=false;
$error=true;
}
}
}else{
$plicht3=true;
}
if($datenschutz_read=='true'){
if(isset($_POST['data_checkbox'])){
$plicht4=true;
} else {
if(!isset($_POST['data_checkbox']) AND isset($_POST["username"])){
$sms.=$language['data_checkbox_not_true'].'<br>';
$plicht4=false;
$error=true;
}
}
}else{
$plicht4=true;
}
if(isset($_POST['send'])){
$plicht1=false;
$plicht2=false;
$error=false;
if(isset($_POST['username'])){
if(isset($_POST['password'])){
if(isset($_POST['passverif'])){
if($_POST['password']==$_POST['passverif']){
if(strlen($_POST['password'])>=4){
$plicht1=true;
$pwend=stripslashes($_POST['password']);
}else{
$sms.=$language['register_4_letter'].'<br>';
$error=true;
}
}else{
$sms.=$language['register_pw_not_pw'].'<br>';
$error=true;
}
}else{
$sms.=$language['register_passwort_again'].'<br>';
$error=true;
}
}else{
$sms.=$language['register_ist_empty'].'<br>';
$error=true;
}
}else{
$sms.=$language['register_username_is_empty'].'<br>';
}
if($plicht1==true){
if(isset($_POST['email'])){
if(preg_match('#^(([a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+\.?)*[a-z0-9!\#$%&\\\'*+/=?^_`{|}~-]+)@(([a-z0-9-_]+\.?)*[a-z0-9-_]+)\.[a-z]{2,}$#i',$_POST['email'])){
$plicht2=true;
}else{
$sms.=$language['email_not_valide'].'<br>';
$error=true;
}
}else{
$sms.=$language['email_is_empty'].'<br>';
$error=true;
}
}
if($plicht1==true AND $plicht2==true AND $plicht3==true AND $plicht4==true){
}else{
$sms.=$language['is_inputs_empty'].'<br>';
$error=true;
}
$stmt = $mysql->prepare("SELECT * FROM `$tabelle` WHERE user = :user"); //Username überprüfen
$stmt->bindParam(":user", $_POST["username"]);
$stmt->execute();
$count = $stmt->rowCount();
if($count == 0){
$error=false;
}else{
$sms.=$language['user_name_givet'].'<br>';
$error=true;
}
$stmt = $mysql->prepare("SELECT * FROM `$tabelle` WHERE email = :email");
$stmt->bindParam(":email", $_POST["email"]);
$stmt->execute();
$count = $stmt->rowCount();
if($count == 0){
$error=false;
}else{
$sms.=$language['email_givet_in'].'<br>';
$error=true;
}
if($error==false){
$ip = $_SERVER['REMOTE_ADDR'];
if($register_email=='true'){
$sid = session_id();
$regkey = rand(1, 99999999);
$active='no';
$register_email_ok=true;
}else{
$sid =0;
$regkey =0;
$active='yes';
$register_email_ok=false;
}
$stmt = $mysql->prepare("INSERT INTO `$tabelle` (user, pass, email,comment,townnumber,land,nachname,phone,address,city,geschlecht,ip,active,regkey,sid)
VALUES (:user, :pass, :email, :comment, :townnumber, :land, :nachname, :phone, :address, :city, :geschlecht, :ip, :active, :regkey, :sid)");
$stmt->bindParam(":user", $_POST['username']);
$hash = password_hash($pwend, PASSWORD_DEFAULT);
$stmt->bindParam(":pass", $hash);
$stmt->bindParam(":email",$_POST['email']);
$stmt->bindParam(":comment",$_POST['comment']);
$stmt->bindParam(":townnumber",$_POST['townnumber']);
$stmt->bindParam(":land",$_POST['land']);
$stmt->bindParam(":nachname",$_POST['nachname']);
$stmt->bindParam(":phone",$_POST['phone']);
$stmt->bindParam(":address",$_POST['address']);
$stmt->bindParam(":city",$_POST['city']);
$stmt->bindParam(":geschlecht",$_POST['geschlecht']);
$stmt->bindParam(":ip",$ip);
$stmt->bindParam(":active",$active);
$stmt->bindParam(":regkey",$regkey);
$stmt->bindParam(":sid",$sid);
$stmt->execute();
if($stmt){
$form = false;
echo "<div class='alert alert-success' role='alert'>
<span class='glyphicon glyphicon-ok' aria-hidden='true'></span>
<span class='sr-only'>Ok:</span>
".$language['register_in_ok'].
</div>";
if($register_email=='true'){
$id = $mysql->lastInsertId();
include('email-to-register.php');
$sweetout=true;
}else{
$sweetout=false;
}
}else{
$form = true;
$sms.=$language['sometimes_errror'];
}
}else{
$sms.=$language['more_errors'];
}
}else{
}
}
?>
<!doctype html>
<html lang="de">
<head>
<?php
include('tamplate/header.php');
?>
</head>
<body id="bodyregister">
<?php
$register_page=true;
include('tamplate/nav.php');
?>
<?php
if(isset($you_logged_in) AND $you_logged_in==true){
?>
<form class="well form-horizontal" action="register.php" method="post" id="contact_form">
<fieldset>
<legend>
<?php
echo $language['register_login_name'];
if(isset($_SESSION['username'])) {
echo $_SESSION['username'];
}
?>
</legend>
<?php
echo "<div class='alert alert-danger' role='alert'>
<span class='glyphicon glyphicon-removing' aria-hidden='true'></span>
<span class='sr-only'>Error:</span>
".$language['register_not_login'].
</div>";
?>
</fieldset>
</form>
<?php
}else{
?>
<div class="container">
<form class="well form-horizontal" action="register.php" method="post" id="contact_form">
<fieldset>
<?php
if(isset($sms) AND $sms!=''){
echo "<div class='alert alert-danger' role='alert'>
<span class='glyphicon glyphicon-removing' aria-hidden='true'></span>
<span class='sr-only'>Error:</span>
$sms
</div>";
}
?>
<legend><?php echo $language['register_legend']; ?></legend>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_name']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input autocomplete="off" type="text" placeholder="First Name" class="form-control" name="username" value="<?php if(isset($_POST['username'])){echo htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8');} ?>" />
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_next_name']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input autocomplete="off" type="text" placeholder="Nach Name" class="form-control" name="nachname" value="<?php if(isset($_POST['nachname'])){echo htmlentities($_POST['nachname'], ENT_QUOTES, 'UTF-8');} ?>" />
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_password']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input autocomplete="off" type="password" placeholder="Password" class="form-control" name="password" value="<?php if(isset($_POST['password'])){echo htmlentities($_POST['password'], ENT_QUOTES, 'UTF-8');} ?>" />
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_password_two']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input autocomplete="off" type="password" placeholder="Password" class="form-control" name="passverif" value="<?php if(isset($_POST['password'])){echo htmlentities($_POST['password'], ENT_QUOTES, 'UTF-8');} ?>" />
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_email']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
<input autocomplete="off" name="email" placeholder="E-Mail Address" class="form-control" value="<?php if(isset($_POST['email'])){echo htmlentities($_POST['email'], ENT_QUOTES, 'UTF-8');} ?>" type="text">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['genders']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-sort"></i></span>
<select name="geschlecht" class="form-control">
<option></option>
<option value="male"><?php echo $language['register_man']; ?></option>
<option value="female"><?php echo $language['register_woman']; ?></option>
<option value="gender"><?php echo $language['register_man_wom']; ?></option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_phone']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
<input name="phone" placeholder="(845)555-1212" class="form-control" value="<?php if(isset($_POST['phone'])){echo htmlentities($_POST['phone'], ENT_QUOTES, 'UTF-8');} ?>" type="text">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_adress']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input name="address" placeholder="Address" class="form-control" value="<?php if(isset($_POST['address'])){echo htmlentities($_POST['address'], ENT_QUOTES, 'UTF-8');} ?>" type="text">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_town']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input name="city" placeholder="city" class="form-control" value="<?php if(isset($_POST['city'])){echo htmlentities($_POST['city'], ENT_QUOTES, 'UTF-8');} ?>" type="text">
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_land']; ?></label>
<div class="col-md-4 selectContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-list"></i></span>
<select name="land" class="form-control selectpicker">
<?php include('town.php'); ?>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_plz']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-home"></i></span>
<input name="townnumber" id="go" placeholder="Postleitzahl" class="form-control" value="<?php if(isset($_POST['townnumber'])){echo htmlentities($_POST['townnumber'], ENT_QUOTES, 'UTF-8');} ?>" type="text">
<select id="testwiese" class="form-control selectpicker"><option value="'.$town.'">Suche ...</option></select>
</div>
</div>
</div>
<script>
selectionChange = function() {
var elStatePage = document.getElementById('go');
elStatePage.value = this.value;
}
var e = document.getElementById('testwiese');
e.onchange = selectionChange;
$('#go').keyup(function() {
var townnumber = $('#go').val();
var was = townnumber.length;
if (was >= 3) {
console.log(townnumber);
$.ajax({
type: 'POST',
url: 'postleitzahlen.php',
data: {
townnumber: townnumber
},
success: function(data) {
document.getElementById('testwiese').innerHTML = data;
}
});
}
});
</script>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['register_comment']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-pencil"></i></span>
<textarea class="form-control" name="comment" placeholder="Project Description">
<?php if(isset($_POST['comment'])){echo htmlentities($_POST['comment'], ENT_QUOTES, 'UTF-8');} ?>
</textarea>
</div>
</div>
</div>
<?php
if($captcha_aktiv=='true'){
?>
<div class="form-group">
<label class="col-md-4 control-label"><?php echo $language['captcha_input']; ?></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-picture"></i></span>
<img src="captcha/captcha.php?RELOAD=" alt="Captcha" title="Klicken, um das Captcha neu zu laden" onclick="this.src+=1;document.getElementById('captcha_code').value='';" style="width:140px;height:40px">
<input autocomplete="off" name="captcha_code" id="captcha_code" placeholder="" class="form-control" value="" type="text">
</div>
</div>
</div>
<?php
}
if($datenschutz_read=='true'){
?>
<div class="form-group">
<label class="col-md-4 control-label"></label>
<div class="col-md-4 inputGroupContainer">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-info-sign"></i><?php echo $language['data_text']; ?>
<input name="data_checkbox" id="data_checkbox" type="checkbox"> <a class="links" href="datenschutz.php"><?php echo $language['data_link_text']; ?></a>
</span>
</div>
</div>
</div>
<?php
}
?>
<div class="form-group">
<label class="col-md-4 control-label"></label>
<div class="col-md-4">
<button type="submit" name="send" class="btn btn-warning"><?php echo $language['register_send']; ?><span class="glyphicon glyphicon-send"></span></button>
</div>
</div>
<span class="small"><?php echo $language['register_text']; ?></span>
</fieldset>
<br>
</form>
</div>
<?php
include('tamplate/footer.php');
?>
</body>
<?php
if($sweetout==true){
echo $scripte;
}
?>
</html>
<?php
}
?>