-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate.php
67 lines (62 loc) · 2.38 KB
/
activate.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
<?php
//The user is re-directed to this file after clicking the activation link
//Signup link contains two GET parameters: email and activation key
session_start();
include('connection.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Account Activation</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<style>
h1{
color:purple;
}
.contactForm{
border:1px solid #7c73f6;
margin-top: 50px;
border-radius: 15px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-offset-1 col-sm-10 contactForm">
<h1>Account Activation</h1>
<?php
//If email or activation key is missing show an error
if(!isset($_GET['email']) || !isset($_GET['key'])){
echo '<div class="alert alert-danger">There was an error. Please click on the activation link you received by email.</div>'; exit;
}
//else
//Store them in two variables
$email = $_GET['email'];
$key = $_GET['key'];
//Prepare variables for the query
$email = mysqli_real_escape_string($link, $email);
$key = mysqli_real_escape_string($link, $key);
//Run query: set activation field to "activated" for the provided email
$sql = "UPDATE users SET activation='activated' WHERE (email='$email' AND activation='$key') LIMIT 1";
$result = mysqli_query($link, $sql);
//If query is successful, show success message and invite user to login
if(mysqli_affected_rows($link) == 1){
echo '<div class="alert alert-success">Your account has been activated.</div>';
echo '<a href="index.php" type="button" class="btn-lg btn-sucess">Log in<a/>';
}else{
//Show error message
echo '<div class="alert alert-danger">Your account could not be activated. Please try again later.</div>';
echo '<div class="alert alert-danger">' . mysqli_error($link) . '</div>';
}
?>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>