-
Notifications
You must be signed in to change notification settings - Fork 0
/
p.php
37 lines (30 loc) · 960 Bytes
/
p.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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "myDB";
// Create connection
// $conn = new mysqli($servername, $username, $password);
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if($_POST){
$name = $_POST['name'];
$age = $_POST['age'];
$bloodgroup = $_POST['bloodgroup'];
$contact = $_POST['contact'];
$location = $_POST['location'];
$sql = "INSERT INTO blood ( name, age, blood_group, contact, location)
VALUES ('$name', '$age','$bloodgroup' , '$contact' , '$location')";
$newURL= "http://localhost/HtmlInnovativeAssignment/home.html";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
header('Location: '.$newURL);
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
mysqli_close($conn);
?>