-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
449 lines (388 loc) · 23.5 KB
/
index.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
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
<?php
session_start();
include("./php/config.php");
// $_SESSION['iddashboard'] $_SESSION['signupas']
if ((array_key_exists("iddashboard", $_SESSION) and $_SESSION['iddashboard'] and $_SESSION['signupas'] == "client") or (array_key_exists("iddashboard", $_COOKIE) and $_COOKIE['iddashboard'] and $_COOKIE['signupas'] == "client" )) {
header('location:client_dashboard');
}
elseif ((array_key_exists("iddashboard", $_SESSION) and $_SESSION['iddashboard'] and $_SESSION['signupas'] == "designer") or (array_key_exists("iddashboard", $_COOKIE) and $_COOKIE['iddashboard'] and $_COOKIE['signupas'] == "designer" )) {
header('location:designer_dashboard');
}
//
$error = "";
if (array_key_exists("submit", $_POST)) {
// connection.php for connecting to database
include("./php/config.php");
if ($error != "") {
$error = "<p>There were error(s) in your form:</p>".$error;
} else {
// checking signup or log in
if ($_POST['signUp'] == '1') {
if (!$_POST['email']) {
$error .= "An Email address is required<br>";
}
if (!$_POST['password']) {
$error .= "A Password is required<br>";
}
if (!$_POST['name']) {
$error .= "A Name is required<br>";
}
if (!$_POST['phone']) {
$error .= "A Phone number is required<br>";
}
if (!$_POST['confirmpassword']) {
$error .= "A Confirm password is required<br>";
}
if ($_POST['confirmpassword'] != $_POST['password'] ) {
$error .= "Password and Confirm password fields do not match<br>";
}
if ($error != "") {
$error = "<p>There were error(s) in your form:</p>".$error;
}
else
{
$tablename = $_POST['fileformat'];
// checking email already taken or not
$query = "SELECT id FROM `$tablename` WHERE email = '".mysqli_real_escape_string($conn, $_POST['email'])."' LIMIT 1";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) {
$error = "That email address is taken.";
} else {
$data = array();
$from_ip = $_SERVER['REMOTE_ADDR'];
$from_browser = $_SERVER['HTTP_USER_AGENT'];
date_default_timezone_set("Asia/Calcutta");
$date_now = date("r");
if($tablename == "client"){
$credit = 200;
$query = "INSERT INTO `$tablename` (`email`, `password`,`name`, `phone`,`from_ip`, `from_browser`,`time`,`Credits`) VALUES ('".mysqli_real_escape_string($conn, $_POST['email'])."', '".mysqli_real_escape_string($conn, $_POST['password'])."','".mysqli_real_escape_string($conn, $_POST['name'])."','".mysqli_real_escape_string($conn, $_POST['phone'])."','$from_ip', '$from_browser','$date_now',$credit)";
}else{
$query = "INSERT INTO `$tablename` (`email`, `password`,`name`, `phone`,`from_ip`, `from_browser`,`time`) VALUES ('".mysqli_real_escape_string($conn, $_POST['email'])."', '".mysqli_real_escape_string($conn, $_POST['password'])."','".mysqli_real_escape_string($conn, $_POST['name'])."','".mysqli_real_escape_string($conn, $_POST['phone'])."','$from_ip', '$from_browser','$date_now')";
}
// inserting email and password
// $query = "INSERT INTO `$tablename` (`email`, `password`,`name`, `phone`,`from_ip`, `from_browser`,`time`) VALUES ('".mysqli_real_escape_string($conn, $_POST['email'])."', '".mysqli_real_escape_string($conn, $_POST['password'])."','".mysqli_real_escape_string($conn, $_POST['name'])."','".mysqli_real_escape_string($conn, $_POST['phone'])."','$from_ip', '$from_browser','$date_now')";
if (!mysqli_query($conn, $query)) {
$error = "<p>Could not sign you up - please try again later.</p>";
} else {
// setting password with hash
$currentrowid = mysqli_insert_id($conn) ;
$hashed_password1 = hash("sha512", $currentrowid);
$hashed_password2 = $hashed_password1.$_POST['password'];
$hashed_password3 = hash("sha512",$hashed_password2);
$query = "UPDATE `$tablename` SET password = '".$hashed_password3."' WHERE id = ".mysqli_insert_id($conn)." LIMIT 1";
$id = mysqli_insert_id($conn);
// $name = mysqli_insert_name($conn);
// $email = mysqli_insert_email($conn);
mysqli_query($conn, $query);
$_SESSION['iddashboard'] = $id;
$_SESSION['signupas'] = $tablename;
// $_SESSION['email'] = $email;
// $querysec = "SELECT * FROM `$tablename` WHERE id = ".mysqli_insert_id($conn)." LIMIT 1";
// $result = mysqli_query($conn, $querysec);
// $row = mysqli_fetch_array($result);
// if (isset($row)) {
// $_SESSION['email'] = $row['email'];
// }
if ($_POST['stayLoggedIn'] == '1') {
setcookie("iddashboard", $id, time() + 60*60*24*365);
setcookie("signupas", $tablename, time() + 60*60*24*365);
}
if($tablename == "client"){
header("Location: client_dashboard");
}else{
header("Location: designer_dashboard");
}
// header("Location: My_Courses");
}
}
}
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Accept and complete design requests and earn money or find a designer and get the perfect design.">
<meta name="author" content="">
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png">
<title>Sign Up</title>
<!-- Bootstrap Core CSS -->
<link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/style.css" rel="stylesheet">
<!-- You can change the theme colors from here -->
<link href="css/colors/blue.css" id="theme" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- ============================================================== -->
<!-- Preloader - style you can find in spinners.css -->
<!-- ============================================================== -->
<div class="d-none d-lg-block">
<div class="preloader">
<svg class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" />
</svg>
</div>
<!-- ============================================================== -->
<!-- Main wrapper - style you can find in pages.scss -->
<!-- ============================================================== -->
<section id="wrapper">
<div class="login-register"
style="/* display: flex; */position: relative;position: fixed;height: 100%;/* align-items: center; */background-image:url(assets/images/background/login-register.jpg);">
</div>
<div
style="width: 100%;/* justify-content: center; */position: absolute;top: 50%;height: 100%;margin: 120px auto;transform: translateY(-50%);/* height: 100%; */">
<div
style="width: 100%;align-items: center;height: 100%;/* margin: 120px auto; */justify-content: center;display:flex;">
<div class="login-box card" style="position: absolute;top: 50%;transform: translateY(-50%);">
<div class="card-body">
<!-- -->
<div class="container">
<div class="container-fluid" id="homePageContainer" style="padding: 0;">
<div class="container" style="width: 100%;">
<div id="error">
<?php if ($error!="")
{
echo '<div class="alert alert-danger" role="alert">'.$error.'</div>';
}
?>
</div>
</div>
</div>
</div>
<!-- -->
<form class="form-horizontal form-material" id="signUpForm" method="post">
<h3 class="box-title m-b-20">Sign Up</h3>
<div class="form-group">
<div class="col-xs-12">
<input class="form-control" type="text" name="name" placeholder="Name">
</div>
</div>
<div class="form-group ">
<div class="col-xs-12">
<input class="form-control" type="email" name="email" placeholder="Email">
</div>
</div>
<div class="form-group ">
<div class="col-xs-12">
<!-- <input class="form-control" type="text" placeholder="Email"> -->
<input class="form-control textradius" type="number" name="phone"
placeholder="Phone number">
</div>
</div>
<div class="form-group ">
<div class="col-xs-12">
<input class="form-control" type="password" name="password"
placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<input class="form-control" type="password" name="confirmpassword"
placeholder="Confirm Password">
</div>
</div>
<!-- -->
<div class="form-group" style="display: flex;">
<div style="width: 40%;align-items: center;display: flex;">
<label class="form-control" style="margin-bottom: 3px;">Sign Up as </label>
</div>
<div style="width: 60%;">
<select class="form-control" name="fileformat" id="fileformat">
<option>client</option>
<option>designer</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-12 font-14" style="padding: 0 !important;">
<div class="checkbox checkbox-primary pull-left p-t-0">
<input id="checkbox-signup" name="stayLoggedIn" value=1 type="checkbox">
<label for="checkbox-signup"> Stay logged in </label>
</div>
</div>
</div>
<!-- -->
<!-- <div class="form-group row">
<div class="col-md-12">
<div class="checkbox checkbox-success">
<input id="checkbox-signup" type="checkbox">
<label for="checkbox-signup"> I agree to all <a href="#">Terms</a></label>
</div>
</div>
</div> -->
<div class="form-group text-center m-t-20">
<div class="col-xs-12">
<input type="hidden" name="signUp" value="1">
<button
class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light"
name="submit" type="submit">Sign Up</button>
</div>
</div>
<div class="form-group m-b-0">
<div class="col-sm-12 text-center">
<div>Already have an account? <a href="login"
class="text-info m-l-5"><b>Log In</b></a></div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
<div class="d-lg-none">
<div class="preloader">
<svg class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" />
</svg>
</div>
<!-- ============================================================== -->
<!-- Main wrapper - style you can find in pages.scss -->
<!-- ============================================================== -->
<section id="wrapper">
<div class="login-register"
style="/* display: flex; */position: relative;position: fixed;height: 100%;/* align-items: center; */background-image:url(assets/images/background/login-register.jpg);">
</div>
<div
style="width: 100%;/* justify-content: center; */position: absolute;top: 50%;height: 100%;margin: 200px auto;transform: translateY(-50%);/* height: 100%; */">
<div
style="width: 100%;align-items: center;height: 100%;/* margin: 120px auto; */justify-content: center;display:flex;">
<div class="login-box card" style="position: absolute;top: 50%;transform: translateY(-50%);">
<div class="card-body">
<!-- -->
<div class="container">
<div class="container-fluid" id="homePageContainer" style="padding: 0;">
<div class="container" style="width: 100%;">
<div id="error">
<?php if ($error!="")
{
echo '<div class="alert alert-danger" role="alert">'.$error.'</div>';
}
?>
</div>
</div>
</div>
</div>
<!-- -->
<form class="form-horizontal form-material" id="signUpFormmob" method="post">
<h3 class="box-title m-b-20">Sign Up</h3>
<div class="form-group">
<div class="col-xs-12">
<input class="form-control" type="text" name="name" placeholder="Name">
</div>
</div>
<div class="form-group ">
<div class="col-xs-12">
<input class="form-control" type="email" name="email" placeholder="Email">
</div>
</div>
<div class="form-group ">
<div class="col-xs-12">
<!-- <input class="form-control" type="text" placeholder="Email"> -->
<input class="form-control textradius" type="number" name="phone"
placeholder="Phone number">
</div>
</div>
<div class="form-group ">
<div class="col-xs-12">
<input class="form-control" type="password" name="password"
placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<input class="form-control" type="password" name="confirmpassword"
placeholder="Confirm Password">
</div>
</div>
<!-- -->
<div class="form-group" style="display: flex;">
<div style="width: 40%;align-items: center;display: flex;">
<label class="form-control" style="margin-bottom: 3px;">Sign Up as </label>
</div>
<div style="width: 60%;">
<select class="form-control" name="fileformat" id="fileformat">
<option>client</option>
<option>designer</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-md-12 font-14" style="padding: 0 !important;">
<div class="checkbox checkbox-primary pull-left p-t-0">
<input id="checkbox-signupmob" name="stayLoggedIn" value=1 type="checkbox">
<label for="checkbox-signupmob"> Stay logged in </label>
</div>
</div>
</div>
<!-- -->
<!-- <div class="form-group row">
<div class="col-md-12">
<div class="checkbox checkbox-success">
<input id="checkbox-signup" type="checkbox">
<label for="checkbox-signup"> I agree to all <a href="#">Terms</a></label>
</div>
</div>
</div> -->
<div class="form-group text-center m-t-20">
<div class="col-xs-12">
<input type="hidden" name="signUp" value="1">
<button
class="btn btn-info btn-lg btn-block text-uppercase waves-effect waves-light"
name="submit" type="submit">Sign Up</button>
</div>
</div>
<div class="form-group m-b-0">
<div class="col-sm-12 text-center">
<div>Already have an account? <a href="login"
class="text-info m-l-5"><b>Log In</b></a></div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- ============================================================== -->
<!-- End Wrapper -->
<!-- ============================================================== -->
<!-- ============================================================== -->
<!-- All Jquery -->
<!-- ============================================================== -->
<script src="assets/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap tether Core JavaScript -->
<script src="assets/plugins/bootstrap/js/popper.min.js"></script>
<script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
<!-- slimscrollbar scrollbar JavaScript -->
<script src="js/jquery.slimscroll.js"></script>
<!--Wave Effects -->
<script src="js/waves.js"></script>
<!--Menu sidebar -->
<script src="js/sidebarmenu.js"></script>
<!--stickey kit -->
<script src="assets/plugins/sticky-kit-master/dist/sticky-kit.min.js"></script>
<script src="assets/plugins/sparkline/jquery.sparkline.min.js"></script>
<!--Custom JavaScript -->
<script src="js/custom.min.js"></script>
<!-- ============================================================== -->
<!-- Style switcher -->
<!-- ============================================================== -->
<script src="assets/plugins/styleswitcher/jQuery.style.switcher.js"></script>
</body>
</html>