-
Notifications
You must be signed in to change notification settings - Fork 2
/
CREATE_TEACHER.php
175 lines (145 loc) · 5.32 KB
/
CREATE_TEACHER.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?php
include 'DB.php';
$msg = '';
$conn = mysqli_connect($servername, $username, $password, $dbname);
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
// Create connection
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if($_GET['NAME'] != ''){
$sql = "INSERT INTO `TEACHER` (`ID`, `NAME`, `USERNAME`, `PASSWORD`, `DEPARTMENT_ID`)
VALUES ('".generateRandomString().'\', \''.$_GET['NAME'].'\', \''.$_GET['USERNAME'].'\', \''.$_GET['PASSWORD'].'\', \''.$_GET['DEPARTMENT_ID'].'\')';
if (mysqli_query($conn, $sql)) {
$msg = "New Teacher Created Successfully";
} else {
$msg = "Error : Use Different Username";
}
}
$sql = "SELECT `ID` FROM `DEPARTMENT`";
echo'<html>
<head>
<title>MANAGE ACCOUNTS PORTAL for HOD</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<link rel="stylesheet" href="assets/css/main.css" />
</head>
<body>
<!-- Wrapper -->
<div id="wrapper">
<!-- Main -->
<div id="main">
<div class="inner">
<!-- Header -->
<header id="header">
<a href="index.html" class="logo"><strong>Geo Attendance</strong> by Govt. Polytechnic</a>
</header>
<br>
<h3>Create Teacher</h3>
<form method="get" action="CREATE_TEACHER.php">
<div class="col uniform">
<div class="6u 12u$(xsmall)">
<input type="text" name="NAME" id="NAME" value="" placeholder="Name" />
</div>
<br>
<div class="6u 12u$(xsmall)">
<input type="text" name="USERNAME" id="USERNAME" value="" placeholder="Username" />
</div>
<br>
<div class="6u 12u$(xsmall)">
<input type="password" name="PASSWORD" id="PASSWORD" value="" placeholder="Password" />
</div>
<br>
<!-- Break -->
<div class="6u 12u$(xsmall) select-wrapper">
<select name="DEPARTMENT_ID" id="DEPARTMENT_ID">';
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
$rows = array();
while($row = mysqli_fetch_assoc($result)) {
echo '<option value="'.$row['ID'].'">'.$row['ID'].'</option>';
}
print json_encode($rows);
} else {
echo "{}";
}
echo'</select>
</div>
<br>
<div class="12u$">
<ul class="actions">
<li><input type="submit" value="Create" class="special" /></li>
<li><input type="reset" value="Reset" /></li>
</ul>
</div>
<h3>'.$msg.'</h3>
</div>
</form>
<!-- Sidebar -->
<div id="sidebar">
<div class="inner">
<!-- Menu -->
<nav id="menu">
<header class="major">
<h2>Menu</h2>
</header>
<ul>
<li>
<span class="opener">Teacher</span>
<ul>
<li><a href="CREATE_TEACHER.php">Create</a></li>
<li><a href="DELETE_TEACHER.php">Delete</a></li>
<li><a href="view_teacher.php">VIEW</a></li>
</ul>
</li>
<!-- <li>
<span class="opener">HOD</span>
<ul>
<li><a href="CREATE_HOD.php">Create</a></li>
<li><a href="DELETE_HOD.php">Delete</a></li>
</ul>
</li> -->
<li>
<span class="opener">CR</span>
<ul>
<li><a href="CREATE_CR.php">Create</a></li>
<li><a href="DELETE_CR.php">Delete</a></li>
<li><a href="view_cr.php">VIEW</a></li>
</ul>
</li>
</ul>
</nav>
<!-- Section -->
<section>
<header class="major">
<h2>Get in touch</h2>
</header>
<ul class="contact">
<li class="fa-envelope-o"><a href="#">principal@gpmumbai.ac.in</a></li>
<li class="fa-phone">090290 01925</li>
<li class="fa-home">49, Kherwadi, A.Y.Jung Marg, Bandra (East), Mumbai, Maharashtra 400051 </li>
</ul>
</section>
</div>
</div>
</div>
<!-- Scripts -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/skel.min.js"></script>
<script src="assets/js/util.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
';
mysqli_close($conn);
?>