-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging.php
executable file
·40 lines (38 loc) · 1.3 KB
/
logging.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
<link rel = 'stylesheet' type = 'text/css' href = 'style.css'>
<script
src="https://code.jquery.com/jquery-3.2.1.js"
integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE="
crossorigin="anonymous"></script>
<?php
require 'users.class.php';
session_start();
if ($_SESSION['status'] === TRUE)
header ("Location: welcome.php");
$users = new Users();
$username = $_POST['username'];
$password = $_POST['password'];
$_SESSION['email'] = $username;
$status = $users->login($username, $password);
if ($status == 1)
{
$_SESSION['status'] = true;
$_SESSION['uid'] = $users->getUserId($username);
header ("Location: welcome.php");
}
else if ($status == 0)
{
$key = rand();
$_SESSION['key'] = $key;
$_SESSION['email'] = $username;
$_SESSION['uid'] = $users->getUserId($username);
$content = "Your unique activation code is: " . hash('whirlpool', $key);
mail($username, "Activate your account!", $content);
echo "<h1 class = 'center'>Enter the verification code we sent you on email:</h1>";
echo "<form action = 'activate.php' method = 'post'>";
echo "<input type = 'text' class = 'login' name = 'hash'>";
echo "<input type = 'submit' class = 'login' value = 'Submit' />";
echo "</form>";
}
else if ($status == -1)
header ("Location: login.php?login=false");
?>