-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhedit.php
135 lines (108 loc) · 3.71 KB
/
hedit.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
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
width: 100vw;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: sans-serif;
font-size: 16px;
background-color: #F0F8FF;
}
input{
width: 100%;
padding: 10px , 20px;
font-size: 1 rem;
margin: 15px 0;
box-sizing: border-box;
border: 3px solid salmon;
border-radius: 5px;
}
input[type="submit"]{
width: 100%;
padding: 20 px 20 px;
border: none;
background-color: red;
color: white;
padding: 10px;
cursor: pointer;
border-radius: 50px;
}
</style>
</head>
<?php
session_start();
$con = mysqli_connect('localhost','root','','COVID');
$hname = $_SESSION['user'];
$nid = $_GET['id'];
if(isset($_POST['update']))
{
$a = $_POST['1std'];
$b = $_POST['2ndd'];
$sql = "select FILLED from DATE where 1ST_DOSE like '$a' AND 2ND_DOSE like '$b' AND NAME like '$hname'";
$result = mysqli_query($con, $sql);
$ccap = mysqli_fetch_array($result);
$sql = "select CAPACITY from HOSPITAL_INFO where NAME like '$hname'";
$result = mysqli_query($con,$sql);
$caphos = mysqli_fetch_array($result);
if(is_null($ccap)){
$ccap[0] = 0;
}
if($ccap[0] == $caphos[0]){
echo "This date is full\n";
header("refresh:1;url= hedit.php");
}else{
if($ccap[0] == 0){
$ccap[0] = 1;
$sql = "insert into DATE values('$a','$b','$hname','$ccap[0]')";
$result = mysqli_query($con,$sql);
$sql = "select 1ST_D,2ND_D from STUDENT_INFO where NID like '$nid'";
$result = mysqli_query($con,$sql);
$da = mysqli_fetch_array($result);
$sql = "select FILLED from DATE where 1ST_DOSE like '$da[0]' AND 2ND_DOSE like '$da[1]' AND NAME like '$hname'";
$result = mysqli_query($con,$sql);
$cur_cap = mysqli_fetch_array($result);
$cur_cap[0] -= 1;
$sql = "update DATE set FILLED = '$cur_cap[0]' where 1ST_DOSE like '$da[0]' AND 2ND_DOSE like '$da[1]' AND NAME like '$hname' ";
$result = mysqli_query($con,$sql);
$sql = "update STUDENT_INFO set 1ST_D = '$a', 2ND_D = '$b' where NID like '$nid'";
$result = mysqli_query($con,$sql);
}else{
$ccap[0]++;
$sql = "update DATE set FILLED = '$ccap[0]' where 1ST_DOSE like '$a' AND 2ND_DOSE like '$b' AND NAME like '$hname'";
$result = mysqli_query($con,$sql);
$sql = "select 1ST_D,2ND_D from STUDENT_INFO where NID like '$nid'";
$result = mysqli_query($con,$sql);
$da = mysqli_fetch_array($result);
$sql = "select FILLED from DATE where 1ST_DOSE like '$da[0]' AND 2ND_DOSE like '$da[1]' AND NAME like '$hname'";
$result = mysqli_query($con,$sql);
$cur_cap = mysqli_fetch_array($result);
$cur_cap[0] -= 1;
$sql = "update DATE set FILLED = '$cur_cap[0]' where 1ST_DOSE like '$da[0]' AND 2ND_DOSE like '$da[1]' AND NAME like '$hname' ";
$result = mysqli_query($con,$sql);
$sql = "update STUDENT_INFO set 1ST_D = '$a', 2ND_D = '$b' where NID like '$nid'";
$result = mysqli_query($con,$sql);
}
}
}
if(isset($_POST['Log Out'])){
header("refresh:1;url=Home.php");
}
?>
<h3>Update Data</h3>
<form method="POST">
<label>1st dose date:</label>
<input type="text" name="1std" value="YEAR-MONTH-DAY">
<br>
<label>2nd dose date:</label>
<input type="text" name="2ndd" value="YEAR-MONTH-DAY">
<br>
<input type="submit" name="update" value="Update">
<br>
</form>
<form action="Home.php" method="POST">
<input style="margin: 7px;width:430px" type="submit" name="Log Out" value="Log Out">
</form>