-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsign_up.php
135 lines (123 loc) · 4.75 KB
/
sign_up.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
<?php
/*
* File: sign_up.php
* Author: Alex Kot
* Copyright: 2018 Alex Kot
* Date: 2018/11/09
* EMail: [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*
*/
require 'back_init.php';
// redirect if User is logged in
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
header('Location: profile.php');
exit;
}
// process sign up form
if (isset($_POST['submit']) && $_POST['submit'] === 'SignUp') {
SignUp($db, $user);
}
//ALTER 'PLACEHOLDER' AND 'VALUE'
if ($user->firstnameErr === '') {
$ph->first = 'E.g. Sarah';
$ph->firstStyle = '';
} else {
$ph->first = $user->firstnameErr;
$ph->firstStyle = 'alertPH';
$user->firstname = '';
}
if ($user->lastnameErr === '') {
$ph->last = 'E.g. Connor';
$ph->lastStyle = '';
} else {
$ph->last = $user->lastnameErr;
$ph->lastStyle = 'alertPH';
$user->lastname = '';
}
if ($user->emailErr === '') {
$ph->email = 'E.g. [email protected]';
$ph->emailStyle = '';
} else {
$ph->email = $user->emailErr;
$ph->emailStyle = 'alertPH';
$user->email = '';
}
if ($user->passErr === '') {
$ph->pass = 'The password only you know';
$ph->passStyle = '';
} else {
$ph->pass = $user->passErr;
$ph->passStyle = 'alertPH';
}
?>
<!--PAGE CONTENTS START-->
<?php include 'front_page_header.php'; ?>
<!-- TOP HEADER with LOGO and BUTTONS -->
<header class="header block">
<div class="float_L side mt10">
 
</div>
<div class="float_L middle mt10">
<?php include 'front_header_button_index.php'; ?>
</div>
<div class="float_L side mt10">
<?php include 'front_header_button_sign_in.php'; ?>
</div>
</header>
<!-- MAIN MAGE DATA -->
<main>
<h2>Sign Up!</h2>
<div class="iblock width456">Hey, <b class="col_green"><?php echo $user->basename; ?></b>! Fill in this form, click 'Sign Up' and<br>start enjoying the wanders we build for you.</div>
<section class="block mt20">
<form class="form width456 iblock formTopLine pa20" method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off"
novalidate>
<!--FIRSTNAME-->
<label for="firstname" id="l_firstname" class="label block"><span class="redmark" title="Required">*</span> First Name:</label>
<input type="text" id="name" name="firstname" required title="Please enter your First name"
class="form_input <?php echo $ph->firstStyle; ?>"
placeholder="<?php echo $ph->first; ?>"
value="<?php echo $user->firstname; ?>"/>
<!--LASTNAME-->
<label for="lastname" id="l_lastname" class="label block"><span class="redmark" title="Required">*</span> Last Name:</label>
<input type="text" id="lastname" name="lastname" required title="Please enter your Last name"
class="form_input <?php echo $ph->lastStyle; ?>"
placeholder="<?php echo $ph->last; ?>"
value="<?php echo $user->lastname; ?>"/>
<!--EMAIL-->
<label for="email" id="l_email" class="label block"><span class="redmark" title="Required">*</span> Email:</label>
<input type="email" id="email" name="email" required title="Please enter valid e-mail address"
class="form_input <?php echo $ph->emailStyle; ?>"
placeholder="<?php echo $ph->email; ?>"
value="<?php echo $user->email; ?>"/>
<!--PASSWORD-->
<label for="password" id="l_password" class="label block"><span class="redmark" title="Required">*</span> Password:</label>
<input type="password" id="password" name="password" required
title="Must contain at least one number and one uppercase and lowercase letter, and be at least three or more characters long"
pattern="(?=.*\d)(?=.*[a-zа-я])(?=.*[A-ZА-Я]).{3,100}$"
class="form_input <?php echo $ph->passStyle; ?>"
placeholder="<?php echo $ph->pass; ?>"/>
<!--SHOW PASSWORD-->
<label class="chbox_container">Show Password
<input type="checkbox" onclick="FormShowPassword()">
<span class="chbox_checkmark"></span>
</label>
<div class="spacer10"><br></div>
<!--FORM BUTTONS-->
<button type="submit" class="btn btn1" name="submit" value="SignUp" onclick="ToggleText2Pass()">Sign Up</button>
<button type="reset" class="btn btn1">Reset</button>
<div class="smaller mt20">Already wandering with us? <a href="sign_in.php" class="smaller">Sign In</a>.</div>
</form>
</section>
</main>
<?php include 'front_page_footer.php'; ?>