forked from jribbers/cvcreate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.php
More file actions
50 lines (41 loc) · 1.38 KB
/
Copy pathverify.php
File metadata and controls
50 lines (41 loc) · 1.38 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
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
include 'inc/package.php';
define('PAGE_TITLE', 'Verify');
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$additionalCSS = ['login'];
function verify($code, $email){
include 'inc/connection.php';
$verifyUser = $connection->prepare('SELECT id FROM users WHERE verified = :code AND email = :email;');
$verifyUser->bindValue(':code', $code, PDO::PARAM_STR);
$verifyUser->bindValue(':email', $email, PDO::PARAM_STR);
try {
$verifyUser->execute();
$count = $verifyUser->rowCount();
$results = $verifyUser->fetch(PDO::FETCH_ASSOC);
} catch (PDOexception $e){
echo 'Something went wrong';
exit;
}
if($count == 1) {
$setVerified = $connection->prepare('UPDATE `users` SET `verified` = "true" WHERE `users`.`id` = :id;');
$id = $results['id'];
$setVerified->bindValue(':id', $id, PDO::PARAM_INT);
try {
$setVerified->execute();
} catch (PDOexception $e){
$error .= 'Something went wrong'."\n";
}
} else {
$error = 'Fout emailadress of verificatiecode.';
}
}
if(isset($_POST['verify']) && isset($_POST['code']) && isset($_POST['email'])) {
verify($_POST['code'], $_POST['email']);
} else if(isset($_GET['code']) && $_GET['email']) {
verify($_GET['code'], $_GET['email']);
}
$view = 'views/verify.php';
include $template;
?>