This repository has been archived by the owner on May 25, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin.php
172 lines (134 loc) · 5.34 KB
/
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
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
<?php
require_once("./basic.php");
require_once("./login.php");
require_once("./logout.php");
require_once("./database.php");
require_once("./action.php");
if(isset($_SESSION['id']) && $_SESSION['id'] == 1){
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Welcome, <?php echo $_SESSION['name']; ?>!</title>
<link rel='stylesheet' href="css/font.css" type='text/css'>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<script>
function regUser() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("formerr").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "actions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
name=document.getElementById('name').value;
password=document.getElementById('password').value;
repassword=document.getElementById('re-password').value;
xhttp.send("reguser=1&name="+name+"&password="+password+"&re-password="+repassword);
document.getElementById('name').value="";
document.getElementById('password').value="";
document.getElementById('re-password').value="";
}
function regComp() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (xhttp.readyState == 4 && xhttp.status == 200) {
document.getElementById("formerr").innerHTML = xhttp.responseText;
}
};
xhttp.open("POST", "actions.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
name=document.getElementById('name').value;
price=document.getElementById('price').value;
quantity=document.getElementById('quantity').value;
xhttp.send("regcomp=1&name="+name+"&price="+price+"&quantity="+quantity);
document.getElementById('name').value="";
document.getElementById('price').value="";
document.getElementById('quantity').value="";
}
</script>
</style>
</head>
<body>
<div id="user">
<form action="./index.php" method="post" >
<div id="logout">
<input id="logoutbutton" type="submit" name="logout" value="Logout" /><br/>
</div>
</form>
<b><?php echo $_SESSION['name'] ?><br/></b>
<a href="/index.php">Home</a>
</div>
<div class="heading">
<h1>Wolf of Wallstreet</h1>
</div>
<div class="form">
<div class="mytab2<?php if(!(isset($_GET['tab'])) || (isset($_GET['tab']) && $_GET['tab']=="users")){ echo("-active"); } ?>" onclick="window.location='?tab=users';">Register Users</div>
<div class="mytab2<?php if(isset($_GET['tab']) && $_GET['tab']=="comps"){ echo("-active"); } ?>" onclick="window.location='?tab=comps';">Register Companies</div>
<div class="tab-contents">
<?php if(!(isset($_GET['tab'])) || (isset($_GET['tab']) && $_GET['tab']=="users")){ ?>
<div id="users">
<h1>Registering new user:</h1>
<h4 class="formerr" id="formerr"><br/></h4>
<center>
<div class="field-wrap">
<label>
Name<span class="req">*</span>
</label>
<input type="text" id="name" required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Password<span class="req">*</span>
</label>
<input type="password" id="password" required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Retype Password<span class="req">*</span>
</label>
<input type="password" id="re-password" required autocomplete="off"/>
</div>
<button onclick="regUser()" class="button button-block"/>Register User</button>
</center>
</div>
<?php } ?>
<?php if(isset($_GET['tab']) && $_GET['tab']=="comps"){ ?>
<div id="users">
<h1>Registering new company:</h1>
<h4 class="formerr" id="formerr"><br/></h4>
<center>
<div class="field-wrap">
<label>
Company Name<span class="req">*</span>
</label>
<input type="text" id="name" required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Initial Offering Price<span class="req">*</span>
</label>
<input type="number" id="price" required autocomplete="off"/>
</div>
<div class="field-wrap">
<label>
Initial Number Stocks to be Floated<span class="req">*</span>
</label>
<input type="number" id="quantity" required autocomplete="off"/>
</div>
<button onclick="regComp()" class="button button-block"/>Register Company</button>
</center>
</div>
<?php } ?>
</div>
</div>
<script src="js/first.js"></script>
<script src="js/index.js"></script>
</body>
</html>
<?php }else{ ?>
Access Denied!
<?php } ?>