-
Notifications
You must be signed in to change notification settings - Fork 0
/
insertpatient.php
38 lines (35 loc) · 1.16 KB
/
insertpatient.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
<?php
session_start();
$servername='localhost';
$username='root';
$password='';
$dbname = "organ_donation";
try {
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$age = $_POST['age'];
$medical_history = $_POST['medical_history'];
$doctor = $_POST['doctor'];
$area = $_POST['area'];
$city = $_POST['city'];
$state = $_POST['state'];
$postal = $_POST['postal'];
$phone = $_POST['phone'];
$Blood_group = $_POST['Blood_group'];
$code=$_SESSION['hospital_ID'];
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
/* set the PDO error mode to exception */
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO patient (first_name,last_name,age,medical_history,doctor,
area,city,state,postal,phone,Blood_group,hospital_id)
VALUES ('$first_name', '$last_name','$age','$medical_history','$doctor',
'$area','$city','$state','$postal','$phone','$Blood_group','$code')";
$conn->exec($sql);
echo "New record created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>