-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_form.php
More file actions
35 lines (29 loc) · 937 Bytes
/
process_form.php
File metadata and controls
35 lines (29 loc) · 937 Bytes
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
<?php
// Include your database connection information here
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "contact";
// Create a connection to the database
$conn = new mysqli("localhost", "root", "", "contact");
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Retrieve form data
$name = $_POST["name"];
$email = $_POST["email"];
$number = $_POST["number"];
$address = $_POST["address"];
$message = $_POST["message"];
// Insert the data into the database
$sql = "INSERT INTO form(name, email, number, address, message)
VALUES ('$name', '$email', '$number', '$address', '$message')";
if ($conn->query($sql) === TRUE) {
echo "Data has been successfully inserted into the database.";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
// Close the database connection
$conn->close();
?>