-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcontact-form.php
47 lines (40 loc) · 1.47 KB
/
contact-form.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
<?php
$fname= $_POST['fname'];
$phone= $_POST['phone'];
$email= $_POST['email'];
$message= $_POST['msg'];
if(isset($fname) && isset($email))
{
global $to_email,$vpb_message_body,$headers;
$to_email="[email protected]";
$email_subject="Inquiry From Contact Page";
$vpb_message_body = nl2br("Dear Admin,\n
The user whose detail is shown below has sent this message from ".$_SERVER['HTTP_HOST']." dated ".date('d-m-Y').".\n
Name: ".$fname."\n
Phone No: ".$phone."\n
Email Address: ".$email."\n
Message: ".$message."\n
Thank You!\n\n");
//Set up the email headers
$headers = "From: $fname <$email>\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Message-ID: <".time().rand(1,1000)."@".$_SERVER['SERVER_NAME'].">". "\r\n";
if(@mail($to_email, $email_subject, $vpb_message_body, $headers))
{
$status='Success';
//Displays the success message when email message is sent
$output="Congrats ".$fname.", Thank you for your inquiry. Our sales team has been notified and will be in touch shortly.";
}
else
{
$status='error';
//Displays an error message when email sending fails
$output="Sorry, your email could not be sent at the moment. Please try again or contact this website admin to report this error message if the problem persist. Thanks.";
}
}
else{
$status='error';
$output="please fill require fields";
}
echo json_encode(array('status'=> $status, 'msg'=>$output));
?>