-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddDosage.php
More file actions
64 lines (55 loc) · 1.82 KB
/
AddDosage.php
File metadata and controls
64 lines (55 loc) · 1.82 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
<?php
require "conn.php";
set_include_path('.;C:\wamp\bin\php\php5.5.12\pear');
include('Crypt/AES.php');
include('Crypt/RSA.php');
include('Crypt/Random.php');
include('Math/BigInteger.php');
$client_response = $_POST["client_response"];
//Decrypt Incoming Data
//---------------------------------------------------------------
$cipher = new Crypt_AES(CRYPT_AES_MODE_ECB);
$symmetricKey = file_get_contents('C:\wamp\www\symmetric.txt');
$cipher->setKey($symmetricKey);
$decryptedData = $cipher->decrypt(base64_decode($client_response));
//---------------------------------------------------------------
//Unpack Incoming Data
//---------------------------------------------------------------
$obj = json_decode($decryptedData);
$tag_id = $obj->{"tag_id"};
$nurse_tag = $obj->{"nurse_tag"};
$t = $obj->{"time"};
$prescription_id = $obj->{"prescription_id"};
//---------------------------------------------------------------
//Store Incoming Data in database
//---------------------------------------------------------------
$patient_id = "";
$nurse_id = "";
$mysql_qry1 = "SELECT `patient_id` FROM `patient` WHERE tag_id='$tag_id'";
if ($result1=mysqli_query($conn,$mysql_qry1))
{
while($row1=mysqli_fetch_row($result1))
{
$patient_id = $row1[0];
}
}
$mysql_qry2 = "SELECT `nurse_id` FROM `nurse` WHERE tag_id='$nurse_tag'";
if ($result2=mysqli_query($conn,$mysql_qry2))
{
while($row2=mysqli_fetch_row($result2))
{
$nurse_id = $row2[0];
}
}
$mysql_qry = "INSERT INTO `hospital`.`dosage` (`dosage_id`, `time`, `patient_id`, `nurse_id`, `prescription_id`) VALUES (NULL, '$t','$patient_id','$nurse_id','$prescription_id')";
if ($result=mysqli_query($conn,$mysql_qry))
{
echo "success";
}
else
{
echo "failed";
}
mysqli_close($conn);
//---------------------------------------------------------------
?>