-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact.php
78 lines (68 loc) · 2.29 KB
/
contact.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
74
75
76
77
78
<?php
// Email Setting
//=======================================
$admin_email = "[email protected]";
$from_name = "sankalp'16";
$con = mysqli_connect('mysql.hostinger.in', 'u937298476_admin', 'Sankalp@2016', 'u937298476_snklp');
$db = mysqli_select_db($con, 'u937298476_snklp');
/*
$con = mysqli_connect('localhost', 'root', '', 'u937298476_snklp');
$db = mysqli_select_db($con, 'u937298476_snklp');
*/
if(isset($_POST['subscriberemail'])) {
$subscriber_email = strip_tags($_POST['subscriberemail']);
if (!filter_var($subscriber_email, FILTER_VALIDATE_EMAIL)) {
echo 5;
exit;
}
else
{
$sql1 = "SELECT * FROM subscription_list";
$result1 = mysqli_query($con, $sql1);
while ($row1 = mysqli_fetch_array($result1)){
$tmp = $row1['email'];
if($tmp==$subscriber_email){
echo 2;
exit;
}
}
$to = $admin_email;
$subject = "Email Suscriber Information";
$message = "Email Address: $subscriber_email";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From:$from_name <$admin_email>";
$headers .= "Reply-To: $admin_email\r\n"."X-Mailer: PHP/".phpversion();
$send = mail($to, $subject, $message, $headers);
$sql = "INSERT INTO subscription_list(email) VALUES ('$subscriber_email')";
mysqli_query($con, $sql);
echo "1";
}
}
if(isset($_POST['contact_email'])) {
$user_name = strip_tags($_POST['contact_name']);
$user_email = strip_tags($_POST['contact_email']);
$user_phone = strip_tags($_POST['contact_phone']);
$comment_text = strip_tags($_POST['contact_text']);
if (!filter_var($user_email, FILTER_VALIDATE_EMAIL)) {
echo 5;
exit;
}
else
{
$to = "$admin_email";
$subject = "New Contact Information";
$message = "Name: $user_name <br/>";
$message .= "Email: $user_email <br/>";
$message .= "Comment: $comment_text <br/>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From:$from_name<$admin_email>";
$headers .= "Reply-To: $admin_email\r\n"."X-Mailer: PHP/".phpversion();
$send = mail($to, $subject, $message, $headers);
$sql = "INSERT INTO contact_list(name, email, phone, message) VALUES ('$user_name','$user_email','$user_phone','$comment_text')";
mysqli_query($con, $sql);
echo "1";
}
}
?>