forked from hammadshahir/PHP-MySQL-ecommerce-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
registration.php
286 lines (254 loc) · 13.1 KB
/
registration.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
<?php require_once('header.php'); ?>
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_settings WHERE id=1");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$banner_registration = $row['banner_registration'];
}
?>
<?php
if (isset($_POST['form1'])) {
$valid = 1;
if(empty($_POST['cust_name'])) {
$valid = 0;
$error_message .= LANG_VALUE_123."<br>";
}
if(empty($_POST['cust_email'])) {
$valid = 0;
$error_message .= LANG_VALUE_131."<br>";
} else {
if (filter_var($_POST['cust_email'], FILTER_VALIDATE_EMAIL) === false) {
$valid = 0;
$error_message .= LANG_VALUE_134."<br>";
} else {
$statement = $pdo->prepare("SELECT * FROM tbl_customer WHERE cust_email=?");
$statement->execute(array($_POST['cust_email']));
$total = $statement->rowCount();
if($total) {
$valid = 0;
$error_message .= LANG_VALUE_147."<br>";
}
}
}
if(empty($_POST['cust_phone'])) {
$valid = 0;
$error_message .= LANG_VALUE_124."<br>";
}
if(empty($_POST['cust_address'])) {
$valid = 0;
$error_message .= LANG_VALUE_125."<br>";
}
if(empty($_POST['cust_country'])) {
$valid = 0;
$error_message .= LANG_VALUE_126."<br>";
}
if(empty($_POST['cust_city'])) {
$valid = 0;
$error_message .= LANG_VALUE_127."<br>";
}
if(empty($_POST['cust_state'])) {
$valid = 0;
$error_message .= LANG_VALUE_128."<br>";
}
if(empty($_POST['cust_zip'])) {
$valid = 0;
$error_message .= LANG_VALUE_129."<br>";
}
if( empty($_POST['cust_password']) || empty($_POST['cust_re_password']) ) {
$valid = 0;
$error_message .= LANG_VALUE_138."<br>";
}
if( !empty($_POST['cust_password']) && !empty($_POST['cust_re_password']) ) {
if($_POST['cust_password'] != $_POST['cust_re_password']) {
$valid = 0;
$error_message .= LANG_VALUE_139."<br>";
}
}
if($valid == 1) {
$token = md5(time());
$cust_datetime = date('Y-m-d h:i:s');
$cust_timestamp = time();
// saving into the database
$statement = $pdo->prepare("INSERT INTO tbl_customer (
cust_name,
cust_cname,
cust_email,
cust_phone,
cust_country,
cust_address,
cust_city,
cust_state,
cust_zip,
cust_b_name,
cust_b_cname,
cust_b_phone,
cust_b_country,
cust_b_address,
cust_b_city,
cust_b_state,
cust_b_zip,
cust_s_name,
cust_s_cname,
cust_s_phone,
cust_s_country,
cust_s_address,
cust_s_city,
cust_s_state,
cust_s_zip,
cust_password,
cust_token,
cust_datetime,
cust_timestamp,
cust_status
) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$statement->execute(array(
strip_tags($_POST['cust_name']),
strip_tags($_POST['cust_cname']),
strip_tags($_POST['cust_email']),
strip_tags($_POST['cust_phone']),
strip_tags($_POST['cust_country']),
strip_tags($_POST['cust_address']),
strip_tags($_POST['cust_city']),
strip_tags($_POST['cust_state']),
strip_tags($_POST['cust_zip']),
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
md5($_POST['cust_password']),
$token,
$cust_datetime,
$cust_timestamp,
0
));
// Send email for confirmation of the account
$to = $_POST['cust_email'];
$subject = LANG_VALUE_150;
$verify_link = BASE_URL.'verify.php?email='.$to.'&token='.$token;
$message = '
'.LANG_VALUE_151.'<br><br>
<a href="'.$verify_link.'">'.$verify_link.'</a>';
$headers = "From: noreply@" . BASE_URL . "\r\n" .
"Reply-To: noreply@" . BASE_URL . "\r\n" .
"X-Mailer: PHP/" . phpversion() . "\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: text/html; charset=ISO-8859-1\r\n";
// Sending Email
mail($to, $subject, $message, $headers);
unset($_POST['cust_name']);
unset($_POST['cust_cname']);
unset($_POST['cust_email']);
unset($_POST['cust_phone']);
unset($_POST['cust_address']);
unset($_POST['cust_city']);
unset($_POST['cust_state']);
unset($_POST['cust_zip']);
$success_message = LANG_VALUE_152;
}
}
?>
<div class="page-banner" style="background-color:#444;background-image: url(assets/uploads/<?php echo $banner_registration; ?>);">
<div class="inner">
<h1><?php echo LANG_VALUE_16; ?></h1>
</div>
</div>
<div class="page">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="user-content">
<form action="" method="post">
<?php $csrf->echoInputField(); ?>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<?php
if($error_message != '') {
echo "<div class='error' style='padding: 10px;background:#f1f1f1;margin-bottom:20px;'>".$error_message."</div>";
}
if($success_message != '') {
echo "<div class='success' style='padding: 10px;background:#f1f1f1;margin-bottom:20px;'>".$success_message."</div>";
}
?>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_102; ?> *</label>
<input type="text" class="form-control" name="cust_name" value="<?php if(isset($_POST['cust_name'])){echo $_POST['cust_name'];} ?>">
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_103; ?></label>
<input type="text" class="form-control" name="cust_cname" value="<?php if(isset($_POST['cust_cname'])){echo $_POST['cust_cname'];} ?>">
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_94; ?> *</label>
<input type="email" class="form-control" name="cust_email" value="<?php if(isset($_POST['cust_email'])){echo $_POST['cust_email'];} ?>">
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_104; ?> *</label>
<input type="text" class="form-control" name="cust_phone" value="<?php if(isset($_POST['cust_phone'])){echo $_POST['cust_phone'];} ?>">
</div>
<div class="col-md-12 form-group">
<label for=""><?php echo LANG_VALUE_105; ?> *</label>
<textarea name="cust_address" class="form-control" cols="30" rows="10" style="height:70px;"><?php if(isset($_POST['cust_address'])){echo $_POST['cust_address'];} ?></textarea>
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_106; ?> *</label>
<select name="cust_country" class="form-control select2">
<option value="">Select country</option>
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_country ORDER BY country_name ASC");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<option value="<?php echo $row['country_id']; ?>"><?php echo $row['country_name']; ?></option>
<?php
}
?>
</select>
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_107; ?> *</label>
<input type="text" class="form-control" name="cust_city" value="<?php if(isset($_POST['cust_city'])){echo $_POST['cust_city'];} ?>">
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_108; ?> *</label>
<input type="text" class="form-control" name="cust_state" value="<?php if(isset($_POST['cust_state'])){echo $_POST['cust_state'];} ?>">
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_109; ?> *</label>
<input type="text" class="form-control" name="cust_zip" value="<?php if(isset($_POST['cust_zip'])){echo $_POST['cust_zip'];} ?>">
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_96; ?> *</label>
<input type="password" class="form-control" name="cust_password">
</div>
<div class="col-md-6 form-group">
<label for=""><?php echo LANG_VALUE_98; ?> *</label>
<input type="password" class="form-control" name="cust_re_password">
</div>
<div class="col-md-6 form-group">
<label for=""></label>
<input type="submit" class="btn btn-primary" value="<?php echo LANG_VALUE_15; ?>" name="form1">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php require_once('footer.php'); ?>