-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddAllergy.php
More file actions
48 lines (39 loc) · 1.41 KB
/
AddAllergy.php
File metadata and controls
48 lines (39 loc) · 1.41 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
<?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'};
$type = $obj->{'type'};
//---------------------------------------------------------------
//Store Incoming Data in database
//---------------------------------------------------------------
$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_qry = "INSERT INTO `hospital`.`allergies` (`allergy_id`, `patient_id`, `type`) VALUES (NULL, '$patient_id', '$type')";
if ($result=mysqli_query($conn,$mysql_qry))
{
echo "success";
}
mysqli_close($conn);
//---------------------------------------------------------------
?>