-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsubmit.php
60 lines (57 loc) · 2.13 KB
/
submit.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
<?php
if (isset($_POST['send'])) {
require "gump.class.php";
$gump = new GUMP();
$_POST = $gump->sanitize($_POST);
$gump->validation_rules(array(
'name' => 'required|max_len,30|min_len,2',
'email' => 'required|valid_email',
'country' => 'required',
'subject' => 'required|max_len,1000|min_len,3',
));
$gump->filter_rules(array(
'name' => 'trim|sanitize_string',
'email' => 'trim|sanitize_email',
));
$validated_data = $gump->run($_POST);
if($validated_data === false) {
?>
<center><h2><font color="white" > <?php echo $gump->get_readable_errors(true); ?> </font></h2></center>
<?php
include ('contact.php');
}
else {
$name = $validated_data['name'];
$email_from = $validated_data['email'];
$country = $validated_data['country'];
$subject = $validated_data['subject'];
$ToEmail = 'resumetemplate@admin.com';
$EmailSubject = 'Site contact form';
$mailheader = "From: " .$email_from. " \r\n";
$mailheader .= "Reply-To: ".$email_from." \r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: " .$name. " ";
$MESSAGE_BODY .= "Email: ". $email_from . " ";
$MESSAGE_BODY .= "country: " .$country . " ";
$MESSAGE_BODY .= "Comment: " .$subject . " ";
$sendmailtoadmin = mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader);
$usersuject = 'Thank you for contacting Sitename';
$mailheader1 = "From: " .$ToEmail. "\r\n";
$mailheader1 .= "Reply-To: " .$ToEmail. "\r\n";
$mailheader1 .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY1 = "Thank you for leaving message on my website.We will contact you asap " ;
$sendmailtouser = mail($email_from, $usersuject, $MESSAGE_BODY1, $mailheader1);
if(!$sendmailtoadmin && !$sendmailtouser) {
echo "<script>alert('Error occured! Please try to send again ' ); </script>";
include ('contact.php');
}
else {
echo "<script>alert('Thanks for your responce. Admin will reply you soon ' );
window.location.href='contact.php'; </script>";
}
}
}
else {
header("location: contact.php");
}
?>