-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinsert.php
51 lines (39 loc) · 1.51 KB
/
insert.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
<?php
if ($_SERVER['REQUEST_METHOD']=='POST')
{
$name=$_POST['name'];
$age=$_POST['age'];
$weight=$_POST['weight'];
$height=$_POST['height'];
$chronic=$_POST['chronic'];
$med=$_POST['med'];
$horm=$_POST['horm'];
$comm=$_POST['comm'];
// echo '<div class="alert alert-warning alert-dismissible fade show" role="alert">
// <strong>SUCCESSFULLY SUBMITTED!</strong> Your entry has been submitted
// <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
// </div>';
// SUBMIT THESE TO A DATABASE
//CONNECTING TO A DATABASE
$servername="localhost";
$username="root";
$password="";
$database="sashakti";
$conn= mysqli_connect($servername,$username,$password,$database);
if (!$conn) {
die("Sorry failed to connect :".mysqli_connect_error());
}
echo"CONNECTION WAS SUCCESSFUL <br>";
$sql="INSERT INTO `medicalrec` (`Name`, `Age`, `Weight(in kg)`, `Height (in cm)`, `Any history of chronic diseases` , `Any history of major medical procedure` , `Any history of hormonal diseases` , `Any comments`) VALUES ('$name', '$age', '$weight', '$height', '$chronic' , '$med' , '$horm' ,'$comm');";
$result=mysqli_query($conn,$sql);
if ($result) {
echo '<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong>RECORD STORED REGISTERED!!!</strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>';
}
else {
echo"Record was not created :".mysqli_error($conn);
}
}
?>