-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendmailcontactus.php
38 lines (32 loc) · 1.22 KB
/
sendmailcontactus.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
<?php
include("connection.php");
if(isset($_POST['sendmessage'])){
$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$to = "[email protected]";
$from = $_REQUEST['email'];
$name = $_REQUEST['name'];
$headers = "From: $from";
$subject = "SunnyScapes Support";
$fields = array();
$fields{"name"} = "Name";
$fields{"email"} = "Email";
$fields{"subject"} = "Subject";
$fields{"message"} = "Message";
$body = "Here is the message you got:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$send = mail($to, $subject, $body, $headers);
$sql="INSERT INTO `contact_us` ( `username`, `email`, `subject`, `message`)
VALUES ('$name', '$email', '$subject', '$message');";
if(mysqli_query($conn,$sql)){
error_log("$sql..",3,"databaseoperations.log");
echo "<script>alert('Your message sent ');</script>";
echo '<script>window.location.href= "contactus.php";</script>';
}else{ $errorconn=mysqli_error($conn);
trigger_error("$errorconn ");
echo '<script>window.location.href= "contactus.php";</script>';
}
}
mysqli_close($conn);
?>