-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbooking.php
57 lines (43 loc) · 1.42 KB
/
booking.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
<?php
//connect to the database.
$link = pg_connect("host=ec2-54-235-74-57.compute-1.amazonaws.com port=5432 dbname=d1gueknm6h2psa user=pwbtzrsrgvgqrq password=AavMrCiPYOhYhVHj173a2tS2EZ sslmode=require options='--client_encoding=UTF8'");
if (!$link) {
die("Error in connection: " . pg_last_error());
}
//Get the data
$Query = "";
$name = $_GET['pat_name'];
$sex = $_GET['sex'];
$age = $_GET['age'];
$add = $_GET['add'];
$uid = $_GET['usr_id'];
$doc_id=$_GET['doc_id'];
$Query = "INSERT INTO booking(name,age,sex,add,uid,doc_id) VALUES('".$name."',".$age.",'".$sex."','".$add."','".$uid."','".$doc_id."')";
$Result = pg_query($link,$Query); //Execute the query
if(!$Result)
{
die("Error in query: 1" . pg_last_error());
}
$Query = "SELECT avail FROM search WHERE doc_id ='".$doc_id."'";
$Result = pg_query($link,$Query); //Execute the query
if(!$Result)
{
die("Error in query:2 " . pg_last_error());
}
$row = pg_fetch_row($Result);
$avail=$row[0];
$avail=$avail-1;
$Query = "UPDATE search SET avail=".$avail."WHERE doc_id = '".$doc_id."'";
$Result = pg_query($link,$Query); //Execute the query
if(!$Result)
{
die("Error in query: 3" . pg_last_error());
}
$Query = "UPDATE doc_details SET avail=".$avail."WHERE doc_id = '".$doc_id."'";
$Result = pg_query($link,$Query); //Execute the query
if(!$Result)
{
die("Error in query:4 " . pg_last_error());
}
header("location:http://lit-journey-1188.herokuapp.com/user_home.html");
?>