-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_admin.php
54 lines (51 loc) · 1.68 KB
/
new_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
<?php
require_once("static/includes/sessions.php");
require_once("static/includes/functions.php");
if(!isset($_SESSION["username"])){
redirect_to('index.php');
}
require_once("static/includes/dbsetup.php");
include "static/includes/layouts/open.php";
?>
<div class="main">
<div class="page row teal lighten-5">
<form method="POST" action="new_admin_action.php" name="admins" onsubmit="return validateForm()">
<div class="col s4">
<p id="error"></p><br><br>
<div class="input-field">
<input type="text" name="username">  <span id="error1"></span>
<label for="username">Username</label>
</div>
<div class="input-field">
<input type="password" name="password" autocomplete="new-password">  <span id="error2"></span>
<label for="password">Password</label>
</div>
<br><br>
<button class="btn" type="submit" name="submit">Done</button>
</div>
</form>
</div>
</div>
<script>
function validateForm(){
var fields = ["username","password"]
var flag=0;
document.getElementById("error1").innerHTML = "";
document.getElementById("error2").innerHTML = "";
if (document.forms["admins"][fields[0]].value === "") {
document.getElementById("error1").innerHTML = "username can't be blank";
flag=1;
}
if (document.forms["admins"][fields[1]].value === "") {
document.getElementById("error2").innerHTML = "password can't be blank";
flag=1;
}
if(flag === 1){
return false;
}
return true;
}
</script>
<?php
include "static/includes/layouts/close.php";
?>