-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path217276.html
159 lines (159 loc) · 7.65 KB
/
217276.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
</head>
<body>
<?php <br/>
$your_email ='yourname@your–website.com';// <<=== update to your email address<br/>
<br/>
session_start();<br/>
$errors = '';<br/>
$name = '';<br/>
$visitor_email = '';<br/>
$user_message = '';<br/>
<br/>
if(isset($_POST['submit']))<br/>
{<br/>
<br/>
$name = $_POST['name'];<br/>
$visitor_email = $_POST['email'];<br/>
$user_message = $_POST['message'];<br/>
///––––––––––––Do Validations–––––––––––––<br/>
if(empty($name)||empty($visitor_email))<br/>
{<br/>
$errors .= "\n Name and Email are required fields. "; <br/>
}<br/>
if(IsInjected($visitor_email))<br/>
{<br/>
$errors .= "\n Bad email value!";<br/>
}<br/>
if(empty($_SESSION['6_letters_code'] ) ||<br/>
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)<br/>
{<br/>
//Note: the captcha code is compared case insensitively.<br/>
//if you want case sensitive match, update the check above to<br/>
// strcmp()<br/>
$errors .= "\n The captcha code does not match!";<br/>
}<br/>
<br/>
if(empty($errors))<br/>
{<br/>
//send the email<br/>
$to = $your_email;<br/>
$subject="New form submission";<br/>
$from = $your_email;<br/>
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';<br/>
<br/>
$body = "A user $name submitted the contact form:\n".<br/>
"Name: $name\n".<br/>
"Email: $visitor_email \n".<br/>
"Message: \n ".<br/>
"$user_message\n".<br/>
"IP: $ip\n"; <br/>
<br/>
$headers = "From: $from \r\n";<br/>
$headers .= "Reply–To: $visitor_email \r\n";<br/>
<br/>
mail($to, $subject, $body,$headers);<br/>
<br/>
header('Location: thank–you.html');<br/>
}<br/>
}<br/>
<br/>
// Function to validate against any email injection attempts<br/>
function IsInjected($str)<br/>
{<br/>
$injections = array('(\n+)',<br/>
'(\r+)',<br/>
'(\t+)',<br/>
'(%0A+)',<br/>
'(%0D+)',<br/>
'(%08+)',<br/>
'(%09+)'<br/>
);<br/>
$inject = join('|', $injections);<br/>
$inject = "/$inject/i";<br/>
if(preg_match($inject,$str))<br/>
{<br/>
return true;<br/>
}<br/>
else<br/>
{<br/>
return false;<br/>
}<br/>
}<br/>
?><br/>
<!DOCTYPE HTML PUBLIC "–//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <br/>
<html><br/>
<head><br/>
<title>Contact Us</title><br/>
<!–– define some style elements––><br/>
<style><br/>
label,a, body <br/>
{<br/>
font–family : Arial, Helvetica, sans–serif;<br/>
font–size : 12px; <br/>
}<br/>
.err<br/>
{<br/>
font–family : Verdana, Helvetica, sans–serif;<br/>
font–size : 12px;<br/>
color: red;<br/>
}<br/>
</style> <br/>
<!–– a helper script for vaidating the form––><br/>
<script language="JavaScript" src="scripts/gen_validatorv31.js" type="text/javascript"></script> <br/>
</head><br/>
<br/>
<body><br/>
<?php<br/>
if(!empty($errors)){<br/>
echo "<p class='err'>".nl2br($errors)."</p>";<br/>
}<br/>
?><br/>
<div id='contact_form_errorloc' class='err'></div><br/>
<form method="POST" name="contact_form" <br/>
action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <br/>
<p><br/>
<label for='name'>Name: </label><br><br/>
<input type="text" name="name" value='<?php echo htmlentities($name) ?>'><br/>
</p><br/>
<p><br/>
<label for='email'>Email: </label><br><br/>
<input type="text" name="email" value='<?php echo htmlentities($visitor_email) ?>'><br/>
</p><br/>
<p><br/>
<label for='message'>Message:</label> <br><br/>
<textarea name="message" rows=8 cols=30><?php echo htmlentities($user_message) ?></textarea><br/>
</p><br/>
<p><br/>
<img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br><br/>
<label for='message'>Enter the code above here :</label><br><br/>
<input id="6_letters_code" name="6_letters_code" type="text"><br><br/>
<small>Can't read the image? click <a href='javascript: refreshCaptcha();'>here</a> to refresh</small><br/>
</p><br/>
<input type="submit" value="Submit" name='submit'><br/>
</form><br/>
<script language="JavaScript"><br/>
// Code for validating the form<br/>
// Visit http://www.javascript–coder.com/html–form/javascript–form–validation.phtml<br/>
// for details<br/>
var frmvalidator = new Validator("contact_form");<br/>
//remove the following two lines if you like error message box popups<br/>
frmvalidator.EnableOnPageErrorDisplaySingleBox();<br/>
frmvalidator.EnableMsgsTogether();<br/>
<br/>
frmvalidator.addValidation("name","req","Please provide your name"); <br/>
frmvalidator.addValidation("email","req","Please provide your email"); <br/>
frmvalidator.addValidation("email","email","Please enter a valid email address"); <br/>
</script><br/>
<script language='JavaScript' type='text/javascript'><br/>
function refreshCaptcha()<br/>
{<br/>
var img = document.images['captchaimg'];<br/>
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;<br/>
}<br/>
</script><br/>
</body><br/>
</html></body></html>