-
Notifications
You must be signed in to change notification settings - Fork 0
/
request_blood.php
301 lines (262 loc) · 12.7 KB
/
request_blood.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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
<?php include("config.php");?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("head.php");?>
</head>
<body>
<?php
include("top_nav.php");
?>
<div class="container" style='margin-top:70px;'>
<div class="row">
<div class="col-lg-12">
<h3 class=" text-danger">Need Blood To Save Life</h3>
<hr>
</div>
</div>
<div class="row centered-form">
<div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title text-center" style="padding:5px;font-size:16px;font-weight:bold"> Need Blood To Save Lifes</h3>
</div>
<div class="panel-body">
<p id="errorBox"></p>
<?php
if(isset($_POST["submit"]))
{
$target_dir = "request_image/";
$file_name=$_FILES["PIC"]["name"];
if($file_name!="")
{
$target_file = $target_dir.rand(100,999). basename($_FILES["PIC"]["name"]);
move_uploaded_file($_FILES["PIC"]["tmp_name"], $target_file);
}
else
{
$target_file ="request_image/no-image.jpg";
}
$sql="INSERT INTO request_blood(NAME,GENDER,BLOOD,BUNIT,HOSP,DISTRICT,POST_CODE,DOC,RDATE,CNAME,EMAIL,CON1,CON2,REASON,PIC,CADDRESS)
VALUES('{$_POST["NAME"]}','{$_POST["GENDER"]}','{$_POST["BLOOD"]}','{$_POST["BUNIT"]}','{$_POST["HOSP"]}','{$_POST["DISTRICT"]}','{$_POST["POST_CODE"]}','{$_POST["DOC"]}','{$_POST["RDATE"]}','{$_POST["CNAME"]}','{$_POST["EMAIL"]}','{$_POST["CON1"]}','{$_POST["CON2"]}','{$_POST["REASON"]}','{$target_file}','{$_POST["CADDRESS"]}')";
if($con->query($sql))
{
echo "<div class='alert alert-success fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Information : </strong>Your Blood request is sent. Admin will contact you soon</div>";
}
else
{
echo "<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Error : </strong>Server busy.Try again later.</div>";
}
}
?>
<form autocomplete="off" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" enctype="multipart/form-data">
<div class="form-group">
<label class="control-label text-danger">Patient Name</label>
<input type="text" placeholder="Patient Name" name="NAME" required id="NAME" class="form-control input-sm">
</div>
<div class="form-group">
<label class="control-label text-danger" for="GENDER">Gender</label>
<select id="gen" name="GENDER" required class="form-control input-sm">
<option value="">Select Gender</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
<div class="form-group">
<label class="control-label text-danger">Required Blood Group</label>
<select name="BLOOD" id="BLOOD" required class="form-control input-sm">
<option value="">Select Blood</option>
<option value="A+">A+</option>
<option value="B+">B+</option>
<option value="O+">O+</option>
<option value="AB+">AB+</option>
<option value="A-">A-</option>
<option value="B-">B-</option>
<option value="O-">O-</option>
<option value="AB-">AB-</option>
</select>
</div>
<div class="form-group">
<label class="control-label text-danger">Need Unit Of Blood</label>
<input type="text" required name="BUNIT" id="BUNIT" class="form-control" placeholder="Insert No Of Unit">
</div>
<div class="form-group">
<label class="control-label text-danger">Hospital Name & Address</label>
<textarea required name="HOSP" id="HOSP" rows="5" style="resize:none;"class="form-control" placeholder="Hospital Full Address"></textarea>
</div>
<div class="form-group">
<label class="control-label text-danger">District</label>
<input type="text" required name="DISTRICT" id="DISTRICT" class="form-control" placeholder="Insert District">
</div>
<div class="form-group">
<label class="control-label text-danger">Post_code</label>
<input type="text" required name="POST_CODE" id="POST_CODE" class="form-control" placeholder="Insert Post_code">
</div>
<div class="form-group">
<label class="control-label text-danger">Doctor Name</label>
<input type="text" placeholder="Doctor Name" class="form-control input-sm" name="DOC" id="DOC">
</div>
<div class="form-group">
<label class="control-label text-danger">When Required</label>
<input type="text" placeholder="MM/DD/YYYY" class="form-control input-sm DATES" name="RDATE" id="RDATE">
</div>
<div class="form-group">
<label class="control-label text-danger">Contact Name</label>
<input type="text" placeholder="Contact Name" class="form-control input-sm" name="CNAME" id="CNAME">
</div>
<div class="form-group">
<label class="control-label text-danger">Address</label>
<textarea required name="CADDRESS" id="CADDRESS" rows="5" style="resize:none;"class="form-control" placeholder="Full Address"></textarea>
</div>
<div class="form-group">
<label class="control-label text-danger">Email ID</label>
<input type="text" placeholder="Contact Email" class="form-control input-sm" name="EMAIL" id="EMAIL">
</div>
<div class="form-group">
<label class="control-label text-danger">Contact No-1</label>
<input type="text" placeholder="Contact Number" class="form-control input-sm" name="CON1" id="CON1">
</div>
<div class="form-group">
<label class="control-label text-danger">Contact No-2</label>
<input type="text" placeholder="Contact Number" class="form-control input-sm" name="CON2" id="CON2">
</div>
<div class="form-group">
<label class="control-label text-danger">Reason For Blood</label>
<textarea required name="REASON" id="REASON" rows="5" style="resize:none;"class="form-control" placeholder="Reason For Blood" name="REASON" id="REASON"></textarea>
</div>
<div class="form-group">
<label class="control-label text-danger" >Upload Photo</label>
<input type="file" onChange="validate(this.value)" name="PIC" id="PIC">
</div>
<div class="form-group">
<button class="btn btn-success" id="BTN" name="submit"> Request</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<?php include("footer.php"); ?>
<script>
$(document).ready(
function(){
$("#BTN").click(function(){
var NAME=$("#NAME").val();
var BLOOD=$("#BLOOD").val();
var BUNIT=$("#BUNIT").val();
var HOSP=$("#HOSP").val();
var DISTRICT=$("#DISTRICT").val();
var POST_CODE=$("#POST_CODE").val();
var DOC=$("#DOC").val();
var RDATE=$("#RDATE").val();
var CNAME=$("#CNAME").val();
var EMAIL=$("#EMAIL").val();
var CON1=$("#CON1").val();
var CON2=$("#CON2").val();
var REASON=$("#REASON").val();
var PIC=$("#PIC").val();
if($("#NAME").val() == "" )
{
$("#NAME").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter Full Name.</div>");
return false;
}
if($("#BLOOD").val() == "" )
{
$("#BLOOD").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Select Blood.</div>");
return false;
}
if($("#BUNIT").val() == "")
{
$("#BUNIT").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter No Of Units.</div>");
return false;
}
if(isNaN($("#BUNIT").val()))
{
$("#BUNIT").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Unit should be numeric.</div>");
return false;
}
if($("#HOSP").val() == "")
{
$("#HOSP").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter Hospital Name and full address.</div>");
return false;
}
if($("#DISTRICT").val() == "")
{
$("#DISTRICT").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter Your DISTRICT name correctly.</div>");
return false;
}
if($("#DOC").val() == "")
{
$("#DOC").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter Docter Name.</div>");
return false;
}
if($("#RDATE").val() == "")
{
$("#RDATE").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Select the Blood Requiered Date .</div>");
return false;
}
if($("#CNAME").val() == "")
{
$("#CNAME").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter Contact Person Name.</div>");
return false;
}
if($("#CADDRESS").val() == "")
{
$("#CADDRESS").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Fill Full Address.</div>");
return false;
}
if($("#CON1").val() == "")
{
$("#CON1").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter your Mobile Number.</div>");
return false;
}
if(isNaN($("#CON1").val()))
{
$("#CON1").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Mobile Number should be Numeric.</div>");
return false;
}
if($("#CON2").val() == "")
{
$("#CON2").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter Alternate Contact No.</div>");
return false;
}
if(isNaN($("#CON2").val()))
{
$("#CON2").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Alternate Contact should be Numeric.</div>");
return false;
}
if($("#REASON").val() == "")
{
$("#REASON").focus();
$("#errorBox").html("<div class='alert alert-danger fade in' ><a href='#' class='close' data-dismiss='alert' aria-label='close'>×</a><strong>Warning : </strong> Please Enter the correct Reason for Blood.</div>");
return false;
}
});
});
function validate(file) {
var ext = file.split(".");
ext = ext[ext.length-1].toLowerCase();
var arrayExtensions = ["jpg" , "jpeg", "png", "bmp", "gif"];
if (arrayExtensions.lastIndexOf(ext) == -1) {
alert("Please upload image file only.");
$("#PIC").val("");
}
}
</script>
</body>
</html>