-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
60 lines (51 loc) · 1.67 KB
/
login.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
$layout_context = 'public';
require_once("static/includes/sessions.php");
require_once("static/includes/functions.php");
if(isset($_SESSION["username"])){
redirect_to('admin.php');
}
require_once("static/includes/dbsetup.php");
include "static/includes/layouts/open.php";
?>
<div class="main">
<h5>Log In to Iqra</h5>
<div class="page row teal lighten-5">
<form role="form" name="login" action="login_action.php" method="post" onsubmit="return validateForm();" >
<div class="col s4">
<div class="input-field">
<input type="text" name="username_" ><span id="error1"></span>
<label for="menu_name">Username</label>
</div>
<div class="input-field">
<input type="password" name="password_" autocomplete="new-password"><span id="error2"></span>
<label for="menu_name">Password</label>
</div><br><br>
<button class="btn" type="submit" name="submit">Log In</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["login"][fields[0]].value === "") {
document.getElementById("error1").innerHTML = "username can't be blank";
flag=1;
}
if (document.forms["login"][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";
?>