-
Notifications
You must be signed in to change notification settings - Fork 0
/
patient.php
284 lines (253 loc) · 10.1 KB
/
patient.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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php require_once('check_login.php');?>
<?php include('head.php');?>
<?php include('header.php');?>
<?php include('sidebar.php');?>
<?php include('connect.php');
if(isset($_POST['btn_submit']))
{
if(isset($_GET['editid']))
{
$sql ="UPDATE patient SET patientname='$_POST[patientname]',admissiondate='$_POST[admissiondate]',admissiontime='$_POST[admissiontime]',address='$_POST[address]',mobileno='$_POST[mobilenumber]',city='$_POST[city]',pincode='$_POST[pincode]',loginid='$_POST[loginid]',bloodgroup='$_POST[select2]',gender='$_POST[gender]',dob='$_POST[dateofbirth]' WHERE patientid='$_GET[editid]'";
if($qsql = mysqli_query($conn,$sql))
{
?>
<div class="popup popup--icon -success js_success-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Success
</h3>
<p>Patient Record Updated Successfully</p>
<p>
<!-- <a href="index.php"><button class="button button--success" data-for="js_success-popup"></button></a> -->
<?php echo "<script>setTimeout(\"location.href = 'view-patient.php';\",1500);</script>"; ?>
</p>
</div>
</div>
<?php
}
else
{
echo mysqli_error($conn);
}
}
else
{
$passw = hash('sha256', $_POST['password']);
function createSalt()
{
return '2123293dsj2hu2nikhiljdsd';
}
$salt = createSalt();
$pass = hash('sha256', $salt . $passw);
$sql ="INSERT INTO patient(patientname,admissiondate,admissiontime,address,mobileno,city,pincode,loginid,password,bloodgroup,gender,dob,status) values('$_POST[patientname]','$_POST[admissiondate]','$_POST[admissiontime]','$_POST[address]','$_POST[mobilenumber]','$_POST[city]','$_POST[pincode]','$_POST[loginid]','$pass','$_POST[select2]','$_POST[gender]','$_POST[dateofbirth]','Active')";
if($qsql = mysqli_query($conn,$sql))
{
?>
<div class="popup popup--icon -success js_success-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Success
</h3>
<p>Patient Record Inserted Successfully</p>
<p>
<!-- <a href="index.php"><button class="button button--success" data-for="js_success-popup"></button></a> -->
<?php echo "<script>setTimeout(\"location.href = 'view-patient.php';\",1500);</script>"; ?>
</p>
</div>
</div>
<?php
}
else
{
echo mysqli_error($conn);
}
}
}
if(isset($_GET['editid']))
{
$sql="SELECT * FROM patient WHERE patientid='$_GET[editid]' ";
$qsql = mysqli_query($conn,$sql);
$rsedit = mysqli_fetch_array($qsql);
}
?>
<script src="https://cdn.ckeditor.com/4.12.1/standard/ckeditor.js"></script>
<div class="pcoded-content">
<div class="pcoded-inner-content">
<div class="main-body">
<div class="page-wrapper">
<div class="page-header">
<div class="row align-items-end">
<div class="col-lg-8">
<div class="page-header-title">
<div class="d-inline">
<h4>Patient</h4>
<!-- <span>Lorem ipsum dolor sit <code>amet</code>, consectetur adipisicing elit</span> -->
</div>
</div>
</div>
<div class="col-lg-4">
<div class="page-header-breadcrumb">
<ul class="breadcrumb-title">
<li class="breadcrumb-item">
<a href="dashboard.php"> <i class="feather icon-home"></i> </a>
</li>
<li class="breadcrumb-item"><a>Patient</a>
</li>
<li class="breadcrumb-item"><a href="add_user.php">Patient</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="page-body">
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-header">
<!-- <h5>Basic Inputs Validation</h5>
<span>Add class of <code>.form-control</code> with <code><input></code> tag</span> -->
</div>
<div class="card-block">
<form id="main" method="post" action="" enctype="multipart/form-data">
<div class="form-group row">
<label class="col-sm-2 col-form-label">Patient Name</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="patientname" id="patientname" placeholder="Enter name...." required="" value="<?php if(isset($_GET['editid'])) { echo $rsedit['patientname']; } ?>" >
<span class="messages"></span>
</div>
<label class="col-sm-2 col-form-label">Mobile No</label>
<div class="col-sm-4">
<input type="number" class="form-control" name="mobilenumber" id="mobilenumber" placeholder="Enter mobilenumber...." required="" value="<?php echo $rsedit['mobileno']; ?>">
<span class="messages"></span>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Admission Date</label>
<div class="col-sm-4">
<input type="date" class="form-control" name="admissiondate" id="admissiondate" placeholder="Enter admissiondate...." required="" value="<?php if(isset($_GET['editid'])) { echo $rsedit['admissiondate']; } ?>" >
<span class="messages"></span>
</div>
<label class="col-sm-2 col-form-label">Admission Time</label>
<div class="col-sm-4">
<input type="time" class="form-control" name="admissiontime" id="admissiontime" placeholder="Enter admissiontime...." required="" value="<?php echo $rsedit['admissiontime']; ?>">
<span class="messages"></span>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Login ID</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="loginid" id="loginid"
value="<?php if(isset($_GET['editid'])) { echo $rsedit['loginid']; } ?>" />
<span class="messages"></span>
</div>
<label class="col-sm-2 col-form-label">Blood Group</label>
<div class="col-sm-4">
<select class="form-control show-tick" name="select2" id="select2">
<option value="">Select</option>
<?php
$arr = array("A+","A-","B+","B-","O+","O-","AB+","AB-");
foreach($arr as $val)
{
if($val == $rsedit['bloodgroup'])
{
echo "<option value='$val' selected>$val</option>";
}
else
{
echo "<option value='$val'>$val</option>";
}
}
?>
</select>
<span class="messages"></span>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">City</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="city" id="city"
value="<?php if(isset($_GET['editid'])) { echo $rsedit['city']; } ?>" />
<span class="messages"></span>
</div>
<label class="col-sm-2 col-form-label">PIN Code</label>
<div class="col-sm-4">
<input class="form-control" type="text" name="pincode" id="pincode"
value="<?php if(isset($_GET['editid'])){ echo $rsedit['pincode']; } ?>" />
<span class="messages"></span>
</div>
</div>
<?php
if(!isset($_GET['editid']))
{
?>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Password</label>
<div class="col-sm-4">
<input class="form-control" type="password" name="password" id="password"/>
<span class="messages"></span>
</div>
<label class="col-sm-2 col-form-label">Confirm Password</label>
<div class="col-sm-4">
<input class="form-control" type="password" name="cnfirmpassword" id="cnfirmpassword"/>
<span class="messages" id="confirm-pw" style="color: red;"></span>
</div>
</div>
<?php } ?>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Gender</label>
<div class="col-sm-4">
<select name="gender" id="gender" class="form-control" required="">
<option value="">-- Select One -- </option>
<option value="Male" <?php if(isset($_GET['editid']))
{ if($rsedit['gender'] == 'Male') { echo 'selected'; } } ?>>Male</option>
<option value="Female" <?php if(isset($_GET['editid']))
{ if($rsedit['gender'] == 'Female') { echo 'selected'; } } ?>>Female</option>
</select>
</div>
<label class="col-sm-2 col-form-label">Date of Birth</label>
<div class="col-sm-4">
<input class="form-control" type="date" name="dateofbirth" max="<?php echo date("Y-m-d"); ?>"
id="dateofbirth" value="<?php echo $rsedit['dob']; ?>" />
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Address</label>
<div class="col-sm-10">
<textarea name="address" id="address" class="form-control"><?php if(isset($_GET['editid'])) { echo $rsedit['address']; } ?></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"></label>
<div class="col-sm-10">
<button type="submit" name="btn_submit" class="btn btn-primary m-b-0">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include('footer.php');?>
<script type="text/javascript">
$('#main').keyup(function(){
$('#confirm-pw').html('');
});
$('#cnfirmpassword').change(function(){
if($('#cnfirmpassword').val() != $('#password').val()){
$('#confirm-pw').html('Password Not Match');
}
});
$('#password').change(function(){
if($('#cnfirmpassword').val() != $('#password').val()){
$('#confirm-pw').html('Password Not Match');
}
});
</script>