-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddadmin.php
143 lines (104 loc) · 4.4 KB
/
addadmin.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
<?php
require('dbconn.php');
?>
<!DOCTYPE html>
<html>
<!-- Head -->
<head>
<title>Library Management </title>
<!-- Meta-Tags -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="keywords" content="Library Member Login Form Widget Responsive, Login Form Web Template, Flat Pricing Tables, Flat Drop-Downs, Sign-Up Web Templates, Flat Web Templates, Login Sign-up Responsive Web Template, Smartphone Compatible Web Template, Free Web Designs for Nokia, Samsung, LG, Sony Ericsson, Motorola Web Design" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- //Meta-Tags -->
<!-- Style --> <link rel="stylesheet" href="css/style.css" type="text/css" media="all">
<!-- Fonts -->
<link href="//fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
<!-- //Fonts -->
</head>
<!-- //Head -->
<!-- Body -->
<body>
<h1>LIBRARY MANAGEMENT </h1>
<div class="container">
<div class="login">
<h2>Sign In</h2>
<form action="index.php" method="post">
<input type="text" Name="RollNo" placeholder="ID number" required="">
<input type="password" Name="Password" placeholder="Password" required="">
<div class="send-button">
<!--<form>-->
<input type="submit" name="signin"; value="Sign In">
</form>
</div>
<div class="clear"></div>
</div>
<div class="register">
<h2>Sign Up</h2>
<form action="index.php" method="post">
<input type="text" Name="Name" placeholder="Name" required>
<input type="text" Name="Email" placeholder="Email" required>
<input type="password" Name="Password" placeholder="Password" required>
<input type="text" Name="PhoneNumber" placeholder="Phone Number" required>
<input type="text" Name="RollNo" placeholder="ID Number" required="">
<select name="Category" id="Category">
<option value="Admin">Admin</option>
</select>
<br>
<br>
<div class="send-button">
<input type="submit" name="signup" value="Sign Up">
</form>
</div>
<p>By creating an account, you agree to our <a class="underline" href="terms.html">Terms</a></p>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<div class="footer w3layouts agileits">
<p> © 2022 LMS Login. King A. Albaracin & Mariabil V. Caga-anan </a></p>
</div>
<?php
if(isset($_POST['signin']))
{$u=$_POST['RollNo'];
$p=$_POST['Password'];
$c=$_POST['Category'];
$sql="select * from LMS.user where RollNo='$u'";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
$x=$row['Password'];
$y=$row['Type'];
if(strcasecmp($x,$p)==0 && !empty($u) && !empty($p))
{//echo "Login Successful";
$_SESSION['RollNo']=$u;
if($y=='Admin')
header('location:admin/index.php');
else
header('location:student/index.php');
}
else
{ echo "<script type='text/javascript'>alert('Failed to Login! Incorrect IDNo or Password')</script>";
}
}
if(isset($_POST['signup']))
{
$name=$_POST['Name'];
$email=$_POST['Email'];
$password=$_POST['Password'];
$mobno=$_POST['PhoneNumber'];
$rollno=$_POST['RollNo'];
$category=$_POST['Category'];
$type='Student';
$sql="insert into LMS.user (Name,Type,Category,RollNo,EmailId,MobNo,Password) values ('$name','$type','$category','$rollno','$email','$mobno','$password')";
if ($conn->query($sql) === TRUE) {
echo "<script type='text/javascript'>alert('Registration Successful')</script>";
} else {
//echo "Error: " . $sql . "<br>" . $conn->error;
echo "<script type='text/javascript'>alert('User Exists')</script>";
}
}
?>
</body>
<!-- //Body -->
</html>