-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverification.php
83 lines (69 loc) · 3.9 KB
/
verification.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
<?php
require('config.php');
if(!accessVerification()){
redirect("index.php");
exit();
}
include('includes/header.php');
?>
<div class="wrap hidden">
<div class="container">
<?php
if(isset($_COOKIE['current-snotice'])){
echo '<div class="notice notice-gen success">' . $_COOKIE['current-snotice'] . '</div>';
}
elseif(isset($_COOKIE['current-enotice'])){
echo '<div class="notice notice-gen error">' . $_COOKIE['current-enotice'] . '</div>';
}
?>
</div>
<div class="modal-wrap verify">
<div class="modal-container">
<div class="modal-head">
<h1>Verify Your Account</h1>
</div>
<div class="modal-body">
<form class="form-wrap" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="post" id="verification-form">
<input type="text" name="code" class="code" placeholder="verification code">
<p class="valid valid-code">Please enter the code attached to his form</p>
<input type="text" name="nick" class="nick" placeholder="nickname">
<p class="valid valid-nick">Please give yourself a nickname</p>
<button class="js-btn btn-orange btn-wide" name="verify" id="verify" disabled>verify</button>
<?php
/*
Verify Player
*/
if(isset($_POST['verify'])){
$code = $nickname = "";
$code = clean_input($dbcon, $_POST['code']);
$nickname = clean_input($dbcon, $_POST['nick']);
$user_to_update = $_COOKIE['current-email'];
$search_nick = mysqli_query($dbcon, "SELECT nickname FROM tbl_players WHERE nickname = '$nickname'");
$fetch_nick = mysqli_num_rows($search_nick);
if($fetch_nick > 0){
echo "<div class='notice error'>Someone has that nickname already. Please choose another nickname.</div>";
}
else{
$query = "UPDATE tbl_players SET nickname = '$nickname', date_reg = now(), date_last_played = now(), status = 'active' WHERE email = '$user_to_update'";
if(mysqli_query($dbcon, $query)){
setcookie('current-snotice', 'Hi ' . $nickname . '! Your account has been verified successfully. Please login to play.', time()+5);
setcookie("valid-code", '', time()-3600);
setcookie("current-email", '', time()-3600);
redirect(SITE_URL);
exit();
}
else{
setcookie('current-enotice', 'Can\'t process your request right now.', time()+5);
}
}
}
?>
<div style="text-align: center">Your Code: <span class='thecode' ><?php echo $_COOKIE['valid-code']; ?></span></div>
</form>
</div>
</div>
</div>
</div>
<?php
include('includes/footer.php');
?>