-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssigned.php
More file actions
195 lines (187 loc) · 4.43 KB
/
Assigned.php
File metadata and controls
195 lines (187 loc) · 4.43 KB
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
session_start();
if(isset($_REQUEST["logout"]))
{
session_unset();
session_destroy();
echo "<script>
location.href='admin.html';
</script>";
}
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Assigned Book</title>
<style type="text/css">
body{
background-image: url("5.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 100vh;
}
ul{
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
position: sticky;
opacity: 0.8;
}
li
{
float: left;
}
li a
{
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
#button{
border: none;
background-color: inherit;
color: white;
padding-top: 2%;
cursor: pointer;
}
#padd{
float: right;
}
.home{
background-color: white;
color: black;
}
#button:hover{
background-color: white;
color: black;
}
li a:hover
{
background-color: white;
color: black;
}
.heading{
/* background-color: grey; */
color: #161162;
text-align: center;
height: 100px;
left: 30px;
margin-top: 2%;
margin-bottom: 20%;
}
.form{
text-align: center;
margin-top: 8%;
padding-top: 2%;
margin-left: 50px;
margin-right: 50px;
padding-top: 15px;
padding-right: 50px;
padding-left: 50px;
font-size: 18px;
opacity: 0.8;
filter: alpha(opacity=60);
background-color: black;
width:320px;
top: 10%;
left: 30%;
position: absolute;
color:white;
}
.edit{
border: none;
border-bottom: 1px solid white;
background: transparent;
outline: none;
}
.button{
margin-top: 1%;
background-color: #08088A;
cursor: pointer;
border:none;
color: WHITE;
width: 100px;
height: 30px;
margin-bottom: 2%;
}
::placeholder{
color: white;
opacity: 0.3;
}
input[type=text]
{
color: white;
}
</style>
</head>
<body>
<ul>
<li><a href="Home.php">Home</a></li>
<li><a href="Search_user.php" class="active">Users</a></li>
<li><a href="Create_acc.php">Create account for user</a></li>
<li><a href="Assigned.php" class="home">Assigned Book to user</a></li>
<li><a href="Delete_acc.php">Delete user account</a></li>
<li id="padd"> <form class="" action="" method="post">
<a href=""><input id="button" type="submit" name="logout" value="Logout"></a>
</form></li>
</ul>
<div class="main">
<div class="heading">
<p>A user can issue one book at a time..</p>
<h1>Assigned Book to User</h1>
</div>
<div class="form">
<form class="tab" action="" method="post">
Username:<br><br><input class="edit" type="text" name="Name" placeholder="Enter name" required><br><br>
Book_id:<br><br><input class="edit" type="text" name="id" placeholder="enter valid number" required><br><br>
<input class="button" type="submit" name="assign" value="Assign Book"> <input class="button" type="reset" name="" value="Reset">
</form>
</div>
</div>
</body>
</html>
<?php
if(isset($_REQUEST["assign"]))
{
$name=$_POST["Name"];
$id=$_POST["id"];
$con=new mysqli("localhost","root","Harshil479","library_project");
$sql="SELECT * FROM books where `id`='$id'";
$result=mysqli_query($con,$sql);
if($result)
{
$row=mysqli_fetch_row($result);
// echo "$row[5]";
$quan=$row[5]-1;
// echo "$quan";
$sql1="UPDATE `books` SET `quantity` = '$quan' WHERE `books`.`id` = '$id'";
mysqli_query($con,$sql1);
}
else
{
echo "<script>
alert('Book is not available');
</script>";
}
$sql2="UPDATE `user_table` SET `Assigned_Book_id` = '$id' WHERE `user_table`.`username` = '$name'";
$result1=mysqli_query($con,$sql2);
if($result1)
{
echo "<script>
alert('Book is Assigned');
</script>";
}
else
{
echo "<script>
alert('Username is not available');
</script>";
}
}
?>