-
Notifications
You must be signed in to change notification settings - Fork 0
/
addtopic.php
120 lines (92 loc) · 4.02 KB
/
addtopic.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
<?php
include_once("analyticstracking.php");
include 'internal_api.php';
session_start();
if (!empty($_POST)){
$topic=array();
$topic=addTopic($_POST["topic"]);
}
if (!isset($_SESSION["loggedin"]) && $_SESSION["loggedin"]!=1 ){
$_SESSION["intended"]="addtopic";
header( 'Location: login') ;
}
else if (!isset($_SESSION["instructor"]) && $_SESSION["instructor"]==0){
echo'YOU DO NOT HAVE ACCESS';
}
else{
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>LearningX | Your perfect Java teacher</title>
<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="bower_components/paper-submit/paper-submit.html">
<link rel="import" href="bower_components/paper-input/paper-textarea.html">
<link rel="import" href="bower_components/iron-form/iron-form.html">
<link rel="import" href="bower_components/paper-toast/paper-toast.html">
<link rel="import" href="bower_components/paper-input/paper-input.html">
<link rel="import" href="bower_components/paper-button/paper-button.html">
<link rel="stylesheet" href="css/normalize.css">
<link rel='stylesheet prefetch' href='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css'>
<link rel="stylesheet" href="css/style.css">
<link rel="import" href="bower_components/paper-material/paper-material.html">
<link rel="import" href="bower_components/paper-styles/paper-styles.html">
<link rel="import" href="css/my_custom_styles.html">
</head>
<body>
<?php include 'menu.php';?>
<div class="container">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<?php include 'header.html';?>
<?php if (isset($_SESSION["instructor"]) && $_SESSION["instructor"]==1){ ?>
<center>
<h3>Create Topic</h2>
<paper-material elevation="3" class="card">
<center>
<?php if (isset($topic[0]["created"]) && $topic[0]["created"]=='Success'){?>
<h4 style="color:red">Topic Created</h4>
<?php }?>
<form is="iron-form" id="form" method="post">
<paper-input class="my-class" id="topic" name="topic" label="Enter a New Topic Name" required></paper-input>
<br>
<button type="submit" id="SubmitButton" name="submit" style="visibility:hidden;"></button>
<paper-toast id="toast" text="Registering..."></paper-toast>
<paper-toast visible="false" id="toast2" text="Login Failed, Please Try Again..."></paper-toast>
<paper-button id="my-button" class="my-button" style="display:block;" raised onclick="submitForm();">Add Topic</paper-button>
</form>
<script>function submitForm(){
if (document.getElementById('topic').value==''){
document.querySelector('#toast2').text= "Topic Name Cannot be blank! Please Re-enter";
document.querySelector('#toast2').show();
}
else{
document.querySelector('#toast').text= "Adding Topic...";
document.querySelector('#toast').show();
document.getElementById('SubmitButton').click();
console.log("Submitted!")
}
}
</script>
</center>
<br />
</paper-material>
</center>
<?php } else {?>
<h1> you do not have access</h1>
<?php }?>
</div>
</div>
</div>
</div>
<!-- /#page-content-wrapper -->
</div>
<!-- /#wrapper -->
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'></script>
<script src="js/index.js"></script>
<?php }?>
</body>
</html>