-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookie-set.php
More file actions
63 lines (56 loc) · 2.01 KB
/
Copy pathcookie-set.php
File metadata and controls
63 lines (56 loc) · 2.01 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
59
60
61
62
63
<?php
session_start();
if (isset($_SESSION['id'])) {
$user_id = $_SESSION['id'];
include './connection.php';
if ($_SESSION['type'] == 'admin') {
setcookie('phonebook-admin', $_SESSION['type'], time()+30);
header('location: ./admin.php');
} else {
$retrieveDataQuery = "SELECT securityQuestion, securityAnswer FROM registeration WHERE user_id = '$user_id'";
$retrieveData = $con -> query($retrieveDataQuery);
$row = $retrieveData -> fetch_assoc();
// print_r ($row);
if (isset($_POST['submit'])) {
$securityAnswer = strtolower($_POST['security-answer']);
print $securityAnswer;
if ($securityAnswer === $row['securityAnswer']) {
setcookie('phonebook-user', $_SESSION['type'], time()+30);
header('location: ./home.php');
print 'beep';
} else {
session_destroy();
header('location: ./index.php');
}
}
}
} else {
header('location: ./index.php');
}
?>
<head>
<title>Authentication</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
</head>
<body>
<div class="container">
<form class="s12" method="post">
<div class="row">
<div class="input-field col s6">
<input type="text" value="<?php echo $row['securityQuestion'] ?>" disabled>
<label for="security-question">Securtiy Question</label>
</div>
<div class="input-field col s6">
<input id="security-answer" type="text" class="validate" name="security-answer" required>
<label for="security-answer">Answer</label>
</div>
<div class="row">
<div class="center">
<input type="submit" value="submit" name="submit" class="input-field input-btn btn">
</div>
</div>
</form>
</div>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>