-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
53 lines (38 loc) · 1.3 KB
/
api.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
<?php
header('Access-Control-Allow-Origin: *');
$user="id16550298_drug1";
$pass="3%0xUW!Su!WT+^FV";
$db= "id16550298_drug";
$conn = new mysqli("localhost",$user,$pass,$db);
// Check connection
if ($conn -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
if(isset($_GET['reg'])){
$reg = $_GET['reg'];
$reg = str_replace("'","",$reg);
$reg = str_replace('"','',$reg);
if(!empty($reg)){
$query =mysqli_query($conn,"SELECT*FROM drug_info WHERE RegNo='$reg' LIMIT 1");
if(mysqli_num_rows($query)==1){
$data = mysqli_fetch_assoc($query);
$arr =array('Status'=>'success','Brand'=>$data['BrandName'],'RegNo'=>$data['RegNo'],'Response'=>'this drug is verified by NAFDAC');
echo json_encode($arr);
exit();
} else {
$arr = array('Status'=>'fail','RegNo'=>$reg,'Response'=>'This drug is not verified by NAFDAC');
echo json_encode($arr);
exit();
}
} else {
$arr = array('Status'=>'fail', 'Response'=>'reg can not be empty');
echo json_encode($arr);
exit();
}
} else {
$arr = array('Status'=>'fail','Respose'=>'reg is not set');
echo json_encode($arr);
exit();
}
?>