-
Notifications
You must be signed in to change notification settings - Fork 5
/
feedback.php
77 lines (68 loc) · 2.08 KB
/
feedback.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
<?php
if(file_exists("functions.php")) include("functions.php"); else exit;
function spamcheck($field) {
// Sanitize e-mail address
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
// Validate e-mail address
if(filter_var($field, FILTER_VALIDATE_EMAIL)) {
return TRUE;
} else {
return FALSE;
}
}
if (isset($_POST["email"])) {
// Check if "from" email address is valid
$mailcheck = spamcheck($_POST["email"]);
if ($mailcheck==FALSE) {
//echo "Invalid input";
} else {
$email = $_POST["email"]; // sender
$name = $_POST["fname"];
$number = $_POST["number"];
$message = $_POST["comment"];
// message lines should not exceed 70 characters (PHP rule), so wrap it
$message = wordwrap($message, 3000);
// Email
if (!preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $email))
{
$err_email = 'Please enter valid Email.';
echo $err_email;
}
else if(!preg_match('/^[0-9]{10,10}$/', $number))
{
$err_mobile = 'Please enter valid Mobile Number.';
echo $err_mobile;
}
else if(strlen($message) < 5)
{
$err_message = 'Please write valid text in Comment';
echo $err_message;
}
else
{
global $mysql_hostname,$mysql_username,$mysql_password,$mysql_dbname;
$conn = mysql_connect($mysql_hostname, $mysql_username, $mysql_password);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($mysql_dbname);
$query = "INSERT INTO feedback(name,email,mobile,comment) VALUES('$name','$email', '$number', '$message')";
$retval = mysql_query( $query, $conn);
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
echo "Error Occured !!";
}
else
{
echo "Thanks for your feedback !!";
}
mysql_close($conn);
// send mail
mail("[email protected]",$name." ".$number,$message,"From: $email\n");
//echo "Thank you for sending us feedback";
}
}
}
?>