-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_php_alternative.txt
49 lines (42 loc) · 1.53 KB
/
admin_php_alternative.txt
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
<!--This is the another alternative for direct mail system inbuild in php-->
<?php
// Retrieve form data
$name = $_POST['pname'];
$email = $_POST['pemail'];
$phone = $_POST['pcontact'];
// Database connection settings
$servername = 'server_name_of_cpanel';
$username = "database_editor_name";
$password = "user_password";
$dbname = "database_name";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Insert data into the database
$sql = "INSERT INTO Contactdetails (User_Name, Email, Phone_No) VALUES ('$name', '$email', '$phone')";
if ($conn->query($sql) === true) {
echo "We Will Contact You Soon!";
//to redirect at home page again
header("refresh: 1; url = https://panameragroup.com/");
$content = "You have a new appointment request for Panamera from : $name \n
Appointment Details:\n
Name: $name \n
Email: $email \n
Phone Number: $phone \n
Please contact $name at $email or $phone to schedule or confirm the appointment time.\n
Thank you";
$recipient = "[email protected]";
$ccRecipient = "[email protected]";
$mailheader = "From: $email \r\n";
$mailheader .= "CC: $ccRecipient \r\n";
$subject = "You have a new appointment request";
mail($recipient, $subject, $content, $mailheader) or die("Error!");
} else {
echo "Error: ";
}
// Close the database connection
$conn->close();
?>