-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
37 lines (30 loc) · 916 Bytes
/
functions.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
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
// Database credentials
$host = 'localhost';
$username = 'root';
$password = '';
$database = 'adamspeak_db';
// Create a connection to the database
$conn = new mysqli($host, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare and bind the SQL statement
$sql = "INSERT INTO hire (name, email, phone, message) VALUES (?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssss", $name, $email, $phone, $message);
// Execute the statement
if ($stmt->execute()) {
echo "Form submitted successfully! Await for my Reply!";
} else {
echo "Error: " . $stmt->error;
}
// Close the statement and the database connection
$stmt->close();
$conn->close();
?>