-
Notifications
You must be signed in to change notification settings - Fork 0
/
contactform.php
73 lines (47 loc) · 1.7 KB
/
contactform.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<html>
<head>
</head>
<body>
<?php
$Name = addslashes($_POST['Name']);
$Email = addslashes($_POST['Email']);
$Telephone = addslashes($_POST['Telephone']);
$Subject = addslashes($_POST['Subject']);
$Message = addslashes($_POST['Message']);
// $servername = "localhost";
// $username = "root";
// $password = "";
// $dbname = "sobie";
include('dbcreds.php');
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
$sql = "INSERT INTO inquiries (Email,Name,Telephone,Subject,Message)
VALUES ('$Email','$Name','$Telephone','$Subject','$Message')";
//var_dump($sql);
// Check connection
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
// I want this to go back to the active page that they subnmitd on.
header("Location:contactthankyou.html");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
<!-- MAIL FUNCTION-->
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['Email'])) {
//Email information
$admin_email = "[email protected]";
$email = $_REQUEST['Email'];
$subject = $_REQUEST['Subject'];
$comment = $_REQUEST['Message'];
//send email
mail($admin_email, "$subject", $comment, "From:" . $Emailmail);
//Email response
echo "Thank you for contacting us, We will contact you shortly!";
}
?>
</body>
</html>