The following files exists in this folder. Click to view.
email.php
index.php
login.php
logout.php
index.php
86 lines ASCII Windows (CRLF)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
session_start();
$password = $_SESSION['access'];
if ($password != "123abc") {
header("Location: login.php");
die();
}
$questions = [
[
"question" => "What is question 2?",
"correctAnswer" => "What is the answer to question 1?",
"providedAnswer" => "",
],
[
"question" => "What is the answer to question 1?",
"correctAnswer" => "What is the answer to question 1?",
"providedAnswer" => "",
],
[
"question" => "What is the answer to...",
"correctAnswer" => "1",
"providedAnswer" => "",
]
];
if (isset($_POST["email"])) {
$answering = true;
for ($i = 0; $i < count($questions); $i++) {
if (!isset($_POST["a" . $i])) {
$answering = false;
break;
}
$questions[$i]["providedAnswer"] = $_POST["a" . $i];
}
if ($answering) {
ob_start();
include 'email.php';
$output = ob_get_clean();
$headers['MIME-Version'] = 'MIME-Version: 1.0';
$headers['Content-type'] = 'text/html; charset=iso-8859-1';
mail($_POST["email"], "form", $output, $headers);
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form method="POST">
<?php for ($i = 0; $i < count($questions); $i++) {
$question = $questions[$i];
?>
<p><?php echo $question["question"] ?></p>
<input name="a<?php echo $i ?>" type="text">
<?php } ?>
<p>Email</p>
<input name="email" type="text">
<button>Answer</button>
</form>
<form action="logout.php">
<button>Logout</button>
</form>
</body>
</html>
<?php ?>