-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate.php
More file actions
37 lines (37 loc) · 1.33 KB
/
Copy pathactivate.php
File metadata and controls
37 lines (37 loc) · 1.33 KB
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
<?php
include 'main.php';
$msg = '';
// First we check if the email and code exists...
if (isset($_GET['email'], $_GET['code']) && !empty($_GET['code'])) {
$stmt = $pdo->prepare('SELECT * FROM accounts WHERE email = ? AND activation_code = ?');
$stmt->execute([ $_GET['email'], $_GET['code'] ]);
// Store the result so we can check if the account exists in the database.
$account = $stmt->fetch(PDO::FETCH_ASSOC);
if ($account) {
// Account exists with the requested email and code.
$stmt = $pdo->prepare('UPDATE accounts SET activation_code = ? WHERE email = ? AND activation_code = ?');
// Set the new activation code to 'activated', this is how we can check if the user has activated their account.
$activated = 'activated';
$stmt->execute([ $activated, $_GET['email'], $_GET['code'] ]);
$msg = 'Your account is now activated, you can now login!<br><a href="index.php">Login</a>';
} else {
$msg = 'The account is already activated or doesn\'t exist!';
}
} else {
$msg = 'No code and/or email was specified!';
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1">
<title>Activate Account</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body class="loggedin">
<div class="content">
<p><?=$msg?></p>
</div>
</body>
</html>