-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
56 lines (48 loc) · 1.93 KB
/
login.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
<?php session_start() ?>
<div class="container-fluid">
<form action="" id="login-form">
<div class="form-group">
<label for="" class="control-label">Email</label>
<input type="email" name="email" required="" class="form-control">
</div>
<div class="form-group">
<label for="" class="control-label">Password</label>
<input type="password" name="password" required="" class="form-control">
<small><a href="javascript:void(0)" id="new_account">Create New Account</a></small>
</div>
<button class="button btn btn-info btn-sm">Login</button>
</form>
</div>
<style>
#my_modal .modal-footer {
display: none;
}
</style>
<script>
$('#new_account').click(function () {
my_modal("Create an Account", 'signup.php?redirect=index.php?page=checkout')
});
$('#login-form').submit(function (e) {
e.preventDefault();
$('#login-form button[type="submit"]').attr('disabled', true).html('Logging in...');
if ($(this).find('.alert-danger').length > 0)
$(this).find('.alert-danger').remove();
$.ajax({
url: 'admin/ajax.php?action=login2',
method: 'POST',
data: $(this).serialize(),
error: err => {
alert("An error occured \n" + err);
$('#login-form button[type="submit"]').removeAttr('disabled').html('Login');
},
success: function (resp) {
if (resp == 1) {
location.href = '<?php echo isset($_GET['redirect']) ? $_GET['redirect'] : 'index.php?page=home' ?>';
} else {
$('#login-form').prepend('<div class="alert alert-danger">Email or password is incorrect.</div>');
$('#login-form button[type="submit"]').removeAttr('disabled').html('Login');
}
}
});
});
</script>