-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_admin.php
60 lines (38 loc) · 1.38 KB
/
add_admin.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
<?php
if(isset($_POST['new_admin']))
{
include "db_connect.php";
session_start();
$by_name = $_SESSION['name'];
$name = $_POST['name'];
$password = $_POST['password'];
$branch = $_POST['subject'];
$query = "INSERT INTO admin_login(name,password,branch,by_name)";
$query .= "VALUES ('$name','$password','$branch','$by_name')";
$result = mysqli_query($connection,$query);
if(!$result)
{
die('Query Failed'.mysqli_error($connections));
}
$create_table = "CREATE TABLE IF NOT EXISTS $name(
id int(10) NOT NULL AUTO_INCREMENT,
nquestions int(10) NOT NULL,
positive int(10) NOT NULL,
negative int(10) NOT NULL,
testname varchar(256) NOT NULL ,
questions varchar(256) NOT NULL ,
options varchar(256) NOT NULL ,
answers varchar(256) NOT NULL ,
password varchar(256) NOT NULL ,
testtime int(10) NOT NULL,
students varchar(256) NOT NULL ,
PRIMARY KEY (id)
)";
$create_table_result = mysqli_query($connection,$create_table);
if(!$create_table_result)
{
die('Query Failed'.mysqli_error($connection));
}
header('Location: admin_main_page.php');
}
?>