-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
75 lines (67 loc) · 2.54 KB
/
create.php
File metadata and controls
75 lines (67 loc) · 2.54 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
64
65
66
67
68
69
70
71
72
73
74
75
<?php
session_start();
include 'service/database.php';
$role = $_SESSION["role"];
if(!$role == "operator" or !$role == "admin") {
header ('location: index.php');
}
$msg = null;
if(isset($_POST['submit'])) {
$title = $_POST['title'];
$q1 = $_POST['q1'];
$q2 = $_POST['q2'];
$q3 = $_POST['q3'];
$q4 = $_POST['q4'];
$q5 = $_POST['q5'];
$vis = $_POST["vis"];
$user_id = $_SESSION['user_id'];
try {
$sql1 = "INSERT INTO quizers (user_id, title, q1, q2, q3, q4, q5, visibility) VALUES ('$user_id', '$title', '$q1', '$q2', '$q3', '$q4', '$q5', '$vis')";
if(mysqli_query($conn, $sql1)){
$msg = 'Quizer berhasil dibuat';
} else {
$msg = 'Quizer gagal dibuat';
}
} catch (mysqli_sql_exception) {
$msg = 'Judul Quizer telah digunakan!';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<title>Create</title>
</head>
<body class="dashboard-body">
<?php include 'components/header.php'; ?>
<form action="create.php" method="post">
<label for="title" required><h1>Title</h1></label><br>
<input type="text" name="title" required><br><br>
<label for="q1">Question No. 1</label><br>
<textarea name="q1"></textarea><br><br>
<label for="q2">Question No. 2</label><br>
<textarea name="q2"></textarea><br><br>
<label for="q3">Question No. 3</label><br>
<textarea name="q3"></textarea><br><br>
<label for="q4">Question No. 4</label><br>
<textarea name="q4"></textarea><br><br>
<label for="q5">Question No. 5</label><br>
<textarea name="q5"></textarea><br><br>
<label for="vis">Visibility</label><br>
<input type="radio" name="vis" value="public" required>Public<br>
<input type="radio" name="vis" value="private">Private<br><br>
<input type="submit" name="submit" value="Submit" class="btn-pri"><br>
</form>
<?php
if ($msg == 'Quizer berhasil dibuat') {
echo "<p class='success'>" . $msg . "</p>";
} else {
echo "<p class='failed'>" . $msg . "</p>";
}
?>
</body>
</html>