-
Notifications
You must be signed in to change notification settings - Fork 0
/
student_signup.php
156 lines (138 loc) · 5.35 KB
/
student_signup.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
$title = "Registrer deg - Student";
require_once("database.php");
$mysqli = getConnection(0, 0);
include 'inc/header.php';
session_start();
session_unset();
?>
<link rel="stylesheet" href="style.css">
<h1>Registrer deg - Student</h1>
<form action="student_process_signup.php" method="post" novalidate>
<div>
<label for="name">Navn</label>
<input type="text" id="name" name="name" value="<?= $_SESSION['form_data']['name'] ?? ''; ?>">
<p class="error name_error">
<?php
if (isset($_GET['name_error'])) {
echo htmlspecialchars($_GET['name_error']);
}
?>
</p>
</div>
<div>
<label for="email">E-post</label>
<input type="email" id="email" name="email" value="<?= $email = $_SESSION['form_data']['email'] ?? ''; ?>">
<p class="error email_error">
<?php
if (isset($_GET['email_error'])) {
echo htmlspecialchars($_GET['email_error']);
}
?>
</p>
</div>
<div>
<label for="studie_retning">Studieretning</label>
<select name="studie_retning" id="studie_retning" value="<?= $studie_retning = $_SESSION['studie_retning'] ?? ''; ?>">
<?php
$sql = "CALL getStudyFields()";
$rows = $mysqli->query($sql);
$study_field = mysqli_fetch_all($rows, MYSQLI_ASSOC);
foreach ($study_field as $key => $value) {
echo "<option value='${value['field_code']}'>
{$value['study_name']}
</option>";
$mysqli->next_result();
} ?>
</select>
</div>
<div>
<label for="studie_kull">Studiekull</label>
<select name="studie_kull" id="studie_kull" value="<?= $studie_kull = $_SESSION['studie_kull'] ?? ''; ?>">
<?php
$sql = "CALL getStudySemesters()";
$rows = $mysqli->query($sql);
$study_semester = mysqli_fetch_all($rows, MYSQLI_ASSOC);
foreach ($study_semester as $key => $value) {
echo "<option value='{$value['semester_code']}'>
{$value['semester_name']} </option>";
$mysqli->next_result();
} ?>
</select>
</div>
<div>
<label for=" password">Passord</label>
<input type="password" id="password" name="password" pattern=".{8,}" title="Passordet må være 8 sifra">
<p class="error password_error">
<?php
if (isset($_GET['password_error'])) {
echo htmlspecialchars($_GET['password_error']);
}
?>
</p>
</div>
<div>
<label for="password_confirmation">Gjenta passord</label>
<input type="password" id="password_confirmation" name="password_confirmation">
<p class="error password_confirmation_error">
<?php
if (isset($_GET['password_confirmation_error'])) {
echo htmlspecialchars($_GET['password_confirmation_error']);
}
?>
</p>
</div>
<div>
<h3>Sikkerhetsspørsmål</h3>
<p>Husk sikkerhetsspørsmålene og svarene du gir.</p>
<br>
<label for="security_question">Velg Sikkerhetsspørsmål 1:</label>
<select name="security_question_1" id="security_question_1" value="<?= $security_question_1 = $_SESSION['security_question_1'] ?? ''; ?>">
<?php
$sql = "CALL getSecurityQuestions(1)";
if ($rows = $mysqli->query($sql)) {
$security_question_1 = mysqli_fetch_all($rows, MYSQLI_ASSOC);
foreach ($security_question_1 as $key => $value) {
echo "<option value='{$value['id']}'>
{$value['text']}</option>";
$mysqli->next_result();
}
}
?>
</select>
</div>
<div>
<label for="answer_question_1">Svar:</label>
<input type="text" id="answer_1" name="answer_1" value="<?= $answer_1 = $_SESSION['form_data']['answer_1'] ?? ''; ?>">
</div>
<div>
<label for="security_question">Velg Sikkerhetsspørsmål 2:</label>
<select name="security_question_2" id="security_question_2" value="<?= $security_question_2 = $_SESSION['security_question_2'] ?? ''; ?>">
<?php
$sql = "CALL getSecurityQuestions(2)";
if ($rows = $mysqli->query($sql)) {
$security_question_2 = mysqli_fetch_all($rows, MYSQLI_ASSOC);
foreach ($security_question_2 as $key => $value) {
echo "<option value='{$value['id']}'>
{$value['text']}</option>";
$mysqli->next_result();
}
}
?>
</select>
</div>
<div>
<label for="answer_question_2">Svar:</label>
<input type="text" id="answer_2" name="answer_2" value="<?= $answer_2 = $_SESSION['form_data']['answer_2'] ?? ''; ?>">
</div>
<p class="error">
<?php
if (isset($_GET['error'])) {
echo htmlspecialchars($_GET['error']);
}
?>
</p>
<input type="submit" name="signup" value="Registrer deg">
<p>Har du allerede en bruker? <a href="login.php">Logg inn her</a>.</p>
</form>
<?php include 'inc/footer.php'; ?>