-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.php
49 lines (39 loc) · 1.38 KB
/
verify.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
<?php
if(user_login_status()) {
header('Location: ./index.php?page=index');
exit;
} else {
if(isset($_GET['email']) && !empty($_GET['email']) && isset($_GET['token']) && !empty($_GET['token'])) {
$email = $_GET['email'];
$token = $_GET['token'];
$query ="SELECT * FROM account WHERE email = ? AND token = ?";
$stmt = $pdo->prepare($query);
$stmt->bindValue(1, $email);
$stmt->bindValue(2, $token);
$stmt->execute();
$num_rows = $stmt->rowCount();
if($num_rows == 0){
header('Location: ./index.php?page=login&status=not_exist');
exit;
} elseif ($num_rows > 1){
header('Location: ./index.php?page=login&status=err');
} else {
$account = $stmt->fetch(PDO::FETCH_ASSOC);
$query = "UPDATE account SET active = 1 WHERE id=?";
$stmt = $pdo->prepare($query);
$stmt->execute([$account['id']]);
header("Location: ./index.php?page=login&status=verified");
}
} else{
header("Refresh: 15; url=./index.php?page=login");
echo "Napaka pri podatkih!";
exit;
}
}
?>
<?=template_header("Verify")?>
<div>
<?=$email?>
<br/>
<?=$token?>
</div>