-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
58 lines (51 loc) · 1.46 KB
/
index.php
File metadata and controls
58 lines (51 loc) · 1.46 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
51
52
53
54
55
56
57
58
<?php
require('database.php');
$toDatabase = new database();
session_start();
if (isset($_POST['say_meow'])){
echo '<p>meow</p>';
}
if (isset($_POST['logout_btn'])){
session_destroy();
}
if (isset($_COOKIE['auth_cookie'])){
$isAvalabileToken = $toDatabase->CheckToken($_COOKIE['auth_cookie']);
echo '<div>
<h3>Hello '.$_SESSION["email"].'</h3>
Start testing the authentication app
</div>
<form action="index.php" method="post">
<button type="submit" name="say_meow">Cat!</button>
</form>
<form action="sign_in.php" method="post">
<button type="submit" name="logout_btn">log out</button>
</form>';
}else if (isset($_SESSION['email'])){
echo '<div>
<h3>Hello '.$_SESSION["email"].'</h3>
Start testing the authentication app
</div>
<form action="index.php" method="post">
<button type="submit" name="say_meow">Cat!</button>
</form>
<form action="sign_in.php" method="post">
<button type="submit" name="logout_btn">log out</button>
</form>';
exit();
}
else{
session_destroy();
header('Location:sign_in.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Authentication app</title>
</head>
<body>
</body>
</html>