-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
182 lines (175 loc) · 6.43 KB
/
signup.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
<!DOCTYPE html>
<html lang="en">
<?php include 'header.php' ?>
<body class="hold-transition register-page">
<div class=" col-lg-7">
<div class="register-logo">
<a href="#"><b>Floral Fashion</b> Store</a>
</div>
<?php session_start() ?>
<?php include('admin/db_connect.php'); ?>
<?php
if(isset($_SESSION['login_id'])){
$qry = $conn->query("SELECT * from users where id = {$_SESSION['login_id']} ");
foreach($qry->fetch_array() as $k => $v){
$$k = $v;
}
}
?>
<div class="card">
<div class="card-body register-card-body">
<p class="login-box-msg"><?php echo !isset($id) ? 'Create Account' : 'Manage Account'; ?></p>
<form id="manage-signup">
<input type="hidden" value="<?php echo isset($id) ? $id : '' ?>" name="id">
<div class="col-md-12">
<div class="row">
<div class="col-md-6 border-right">
<div class="input-group mb-3">
<input type="text" class="form-control" name="firstname" required placeholder="First Name" value="<?php echo isset($firstname) ? $firstname : '' ?>">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-user"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input type="text" class="form-control" name="middlename" placeholder="Middle Name" value="<?php echo isset($middlename) ? $middlename : '' ?>">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-user"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input type="text" class="form-control" name="lastname" required placeholder="Last Name" value="<?php echo isset($lastname) ? $lastname : '' ?>">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-user"></span>
</div>
</div>
</div>
<div class="input-group mb-3">
<input type="text" class="form-control" name="contact" required placeholder="Contact Number" value="<?php echo isset($contact) ? $contact : '' ?>">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-mobile"></span>
</div>
</div>
</div>
<div class="mb-3">
<textarea cols="30" rows="3" class="form-control" name="address" required placeholder="Address"><?php echo isset($address) ? $address : '' ?></textarea>
</div>
</div>
<div class="col-md-6">
<div class="input-group mb-3">
<input type="email" class="form-control" name="email" required="" placeholder="Email" value="<?php echo isset($email) ? $email : '' ?>">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-envelope"></span>
</div>
</div>
</div>
<small id="msg"></small>
<div class="input-group mb-3">
<input type="password" class="form-control" name="password" <?php echo isset($id) ? '' : "required" ?> placeholder="Password">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-lock"></span>
</div>
</div>
</div>
<?php if(isset($id)): ?>
<small><i>Leave this field blank if you dont want to change your password.</i></small>
<?php endif; ?>
<div class="input-group mb-3">
<input type="password" class="form-control" name="cpass" <?php echo isset($id) ? '' : "required" ?> placeholder="Retype password">
<div class="input-group-append">
<div class="input-group-text">
<span class="fas fa-lock"></span>
</div>
</div>
</div>
<small id="pass_match" data-status=''></small>
</div>
</div>
</div>
<div class="row">
<!-- <div class="col-8">
<?php if(!isset($id)): ?>
<div class="icheck-primary">
<input type="checkbox" id="agreeTerms" name="terms" value="agree">
<label for="agreeTerms">
I agree to the <a href="#">terms</a>
</label>
</div>
<?php endif; ?>
</div> -->
<!-- /.col -->
<div class="col-4">
<button type="submit" class="btn btn-danger btn-block"><?php echo !isset($id) ? 'Register' : 'Update Account'; ?></button>
</div>
<!-- /.col -->
</div>
</form>
<?php if(!isset($id)): ?>
<a href="login.php" class="text-center">I have account already</a>
<?php endif; ?>
</div>
<!-- /.form-box -->
</div><!-- /.card -->
</div>
<!-- /.register-box -->
<script>
$(document).ready(function(){
$('#manage-signup').submit(function(e){
e.preventDefault()
$('input').removeClass("border-danger")
start_load()
$('#msg').html('')
if($('#pass_match').attr('data-status') != 1){
if($("[name='password']").val() !=''){
$('[name="password"],[name="cpass"]').addClass("border-danger")
end_load()
return false;
}
}
$.ajax({
url:'admin/ajax.php?action=signup',
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
method: 'POST',
type: 'POST',
success:function(resp){
if(resp == 1){
alert_toast('Data successfully saved.',"success");
setTimeout(function(){
location.replace('index.php?page=home')
},750)
}else if(resp == 2){
$('#msg').html("<div class='alert alert-danger'>Email already exist.</div>");
$('[name="email"]').addClass("border-danger")
end_load()
}
}
})
})
$('[name="password"],[name="cpass"]').keyup(function(){
var pass = $('[name="password"]').val()
var cpass = $('[name="cpass"]').val()
if(cpass == '' ||pass == ''){
$('#pass_match').attr('data-status','')
}else{
if(cpass == pass){
$('#pass_match').attr('data-status','1').html('<i class="text-success">Password Matched.</i>')
}else{
$('#pass_match').attr('data-status','2').html('<i class="text-danger">Password does not match.</i>')
}
}
})
})
</script>
<?php include 'footer.php' ?>
</body>
</html>