-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatient_details.php
73 lines (62 loc) · 1.94 KB
/
patient_details.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
<?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 = "";
$usr_name = $_POST['usr_name'];
$age = $_POST['age'];
$sex = $_POST['sex'];
$phno = $_POST['phno'];
$add = $_POST['add'];
$uname = $_POST['uname'];
$pwd = $_POST['pwd'];
$uname_uid = substr($usr_name,0,3);
$Query="SELECT id FROM user_id WHERE status = 'p'";
$Result = pg_query($link,$Query); //Execute the query
if(!$Result)
{
die("Error in query: " . pg_last_error());
}
$row_no= pg_affected_rows($Result);
if($row_no != 0)
{
$row = pg_fetch_row($Result);
$id = $row[0];
$inner_query = "UPDATE user_id SET status = 'o' WHERE id ='".$id."'";
$inner_result = pg_query($link,$inner_query); //Execute the query
if(!$inner_result)
{
die("Error in query: " . pg_last_error());
}
$id=$id+1;
$user_id = $uname_uid.$id;
$inner_query = "INSERT INTO user_id(usr_name,usr_id,status) VALUES('".$usr_name."','".$user_id."','p')";
$inner_result = pg_query($link,$inner_query); //Execute the query
if(!$inner_result)
{
die("Error in query: " . pg_last_error());
}
}
else
{
echo "error in user_id table";
}
$Query = "INSERT INTO patient_details(name,address,age,sex,cno,usr_id) VALUES('".$usr_name."','".$add."',".$age.",'".$sex."','".$phno."','".$user_id."')";
$Result = pg_query($link,$Query); //Execute the query
if(!$Result)
{
die("Error in query: " . pg_last_error());
}
$Query = "INSERT INTO login(uname,pwd,d_or_p,uid_did) VALUES('".$uname."','".$pwd."','p','".$user_id."')";
$Result = pg_query($link,$Query); //Execute the query
if(!$Result)
{
die("Error in query: " . pg_last_error());
}
header("location:http://lit-journey-1188.herokuapp.com/user_home.html?uid=".$user_id."&");
pg_free_result($Result);
pg_close();
?>