Mailform voor template!
Voor mijn standaard templates heb ik een Mailform gemaakt wat klanten zelf kunnen aanpassen,
Maar ik heb nog wat vragen:
1 is deze qua script goed?
2 van de template is er al een style.css en nu heeft deze ook een style.css hoe moet ik dit aanpakken?
*********************************************************
conbtact_form.php
*********************************************************
Code (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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
// Configureer hier je gegevens:
define('SEND_TO', '[email protected]'); // Vul hier het E-mail adres in waar het bericht naar toe moet!
define('SUBJECTS', 'Subject 1, Subject 2, Subject 3'); // ??
define('SUCCESS_MESSAGE', 'Bedankt {name}, uw bericht is naar ons verzonden.');
define('INBOX_MESSAGE', 'Naam: {name} {enter} Bedrijf: {company} {enter} E-mail: {email} {enter} Telefoonnummer: {phone} {enter} Onderwerp: {subject} {enter} Bericht: {enter} {comment}');
// Condifureer uw error messages. Let op! Indien gewenst, alleen de tekst veranderen tussen de rode haakjes!
define('ERROR_MESSAGE_NAME', '(U vergeet uw naam in te vullen.)');
define('ERROR_MESSAGE_EMAIL', '(U vergeet uw e-mail in te vullen.)');
define('ERROR_MESSAGE_EMAIL_INVALID', '(Uw email is ongeldig.)');
define('ERROR_MESSAGE_PHONE_INVALID', '(Uw telefoonnummer is ongeldig.)');
define('ERROR_MESSAGE_SUBJECT', '(U heeft geen onderwerp ingevuld.)');
define('ERROR_MESSAGE_COMMENT', '(U heeft geen bericht ingevuld.)');
define('ERROR_MESSAGE_CAPTCHA', '(Voer de juiste code in.)');
define('ERROR_MESSAGE_CAPTCHA_INVALID', '(Probeer de code opnieuw in te voeren.)');
// Script: Aangeraden niet te veranderen!
@ini_set('session.use_cookies', '1');
@ini_set('session.use_trans_sid', 'false');
@session_set_cookie_params(0, '/');
@session_start();
if (ini_get('register_globals')) {
$globals = array('_SESSION');
foreach ($globals as $global) {
foreach ($GLOBALS[$global] as $key => $value) {
if ($value === @$GLOBALS[$key]) {
unset($GLOBALS[$key]);
}
}
}
}
@ini_set('magic_quotes_gpc', 'Off');
if (ini_get('magic_quotes_gpc')) {
function clean($data) {
if (is_array($data)) {
foreach ($data as $key => $value) {
$data[$key] = clean($value);
}
} else {
$data = stripslashes($data);
}
return $data;
}
$_POST = clean($_POST);
}
function php_self(){
if(isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO'])> 0){
return substr($_SERVER['PHP_SELF'], 0, (strlen($_SERVER['PHP_SELF']) - @strlen($_SERVER['PATH_INFO'])));
}else{
return $_SERVER['PHP_SELF'];
}
}
$subjects = explode(',', SUBJECTS);
$error = FALSE;
$send = FALSE;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$comment = $_POST['comment'];
$captcha = $_POST['captcha'];
$pfind = array(
'+',
'-',
' '
);
$phone_check = str_replace($pfind, '', $phone);
if(empty($name)){
$error_name = ERROR_MESSAGE_NAME;
$error = TRUE;
}
if(empty($email)){
$error_email = ERROR_MESSAGE_EMAIL;
$error = TRUE;
}elseif(!eregi('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', $email)){
$error_email = ERROR_MESSAGE_EMAIL_INVALID;
$error = TRUE;
}
if(!empty($phone)){
if(!ctype_digit($phone_check)){
$error_phone = ERROR_MESSAGE_PHONE_INVALID;
$error = TRUE;
}
}
if(empty($subject)){
$error_subject = ERROR_MESSAGE_SUBJECT;
$error = TRUE;
}
if(empty($comment)){
$error_comment = ERROR_MESSAGE_COMMENT;
$error = TRUE;
}
if(empty($captcha)){
$error_captcha = ERROR_MESSAGE_CAPTCHA;
$error = TRUE;
}elseif($_SESSION['captcha'] != $captcha){
$error_captcha = ERROR_MESSAGE_CAPTCHA_INVALID;
$error = TRUE;
}
if(!$error) {
if(strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
$ent = "\r\n";
}elseif(strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) {
$ent = "\r";
}else{
$ent = "\n";
}
$find = array(
'{name}',
'{company)',
'{email}',
'{phone}',
'{subject}',
'{comment}',
'{enter}'
);
$replace = array(
'name' => $name,
'company' => $company,
'email' => $email,
'phone' => $phone,
'subject' => $subject,
'commment' => $comment,
'enter' => $ent
);
$comment = str_replace($find, $replace, INBOX_MESSAGE);
$boundary = '----=_NextPart_' . md5(rand());
$headers = 'From: ' . $name . '<' . $email . '>' . $ent;
$headers .= 'X-Mailer: PHP/' . phpversion() . $ent;
$headers .= 'MIME-Version: 1.0' . $ent;
$headers .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $ent . $ent;
$message = '--' . $boundary . $ent;
$message .= 'Content-Type: text/plain; charset="utf-8"' . $ent;
$message .= 'Content-Transfer-Encoding: base64' . $ent . $ent;
$message .= chunk_split(base64_encode($comment));
ini_set('sendmail_from', $email);
mail(SEND_TO, $subject, strip_tags(html_entity_decode($message)), $headers);
$send = TRUE;
$success = str_replace($find, $replace, SUCCESS_MESSAGE);
}
}
// Eind: Aangeraden niet te verranderen!
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
<head>
<title>Lexperts Contact Form</title>
<meta name="description" content="Lexperts contact form" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="box">
<? if($send){ ?>
<div id="success"><h1>Email Sent Successfully.</h1><p><?=$success; ?></p></div>
<? }else{ ?>
<div id="form">
<? if($error) { ?><div class="error"><h1>Invalid Form Input</h1></div><? } ?>
<form method="post" action="<?=php_self() ?>">
<label for="name"><span class="required">* </span>Uw naam:
<? if(!empty($error_name)) { echo '<span class="error_message">'.$error_name.'</span>'; }elseif(!empty($name)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<input name="name" type="text" id="name" size="30" <? if(!empty($name)){ echo 'value="' . $name . '"'; } ?> class="text-input" />
<label for="company">Bedrijf:
<? if(!empty($error_company)) { echo '<span class="error_message>'.$error_company.'</span>'; }elseif(!empty($company)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<input name="company" type="text" id="company" size="30" <? if(!empty($company)){ echo 'value="' . $company. '"'; } ?> class="text-input" />
<label for="email"><span class="required">*</span> Email
<? if(!empty($error_email)) { echo '<span class="error_message">'.$error_email.'</span>'; } elseif(!empty($email)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<input name="email" type="text" id="email" size="30" <? if(!empty($email)){ echo 'value="' . $email . '"'; } ?> class="text-input" />
<label for="phone">Telefoonnummer:
<? if(!empty($error_phone)) {?><span class="error_message"><?=$error_phone?></span><? }elseif(!empty($phone)){ ?><img src="image/icon/accept.png" /><? } ?></label>
<input name="phone" type="text" id="phone" size="30" <? if(!empty($phone)){ echo 'value="' . $phone . '"'; } ?> class="text-input" />
<label for="subject"><span class="required">*</span> Onderwerp:
<? if(!empty($error_subject)) { echo '<span class="error_message">'.$error_subject.'</span>'; } elseif(!empty($subject)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<select name="subject" type="text" id="subject">
<? foreach($subjects as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; } ?>
</select>
<label for="comment"><span class="required">*</span> Bericht:
<? if(!empty($error_comment)) { echo '<span class="error_message">'.$error_comment.'</span>'; }elseif(!empty($comment)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<textarea name="comment" id="comment" rows="8"><? if(!empty($comment)){ echo $comment; } ?></textarea>
<label for="captcha"><span class="required">*</span> Ben jij een mens?
<? if(!empty($error_captcha)) { echo '<span class="error_message">'.$error_captcha.'</span>'; } ?></label>
<div class="captcha"><img src="captcha.php" /></div>
<input name="captcha" type="text" id="captcha" size="30" class="text-input-captcha" />
<br />
<input type="submit" class="submit" value="Send" />
</form>
</div>
<? } ?>
</div>
</body>
</html>
?>
// Configureer hier je gegevens:
define('SEND_TO', '[email protected]'); // Vul hier het E-mail adres in waar het bericht naar toe moet!
define('SUBJECTS', 'Subject 1, Subject 2, Subject 3'); // ??
define('SUCCESS_MESSAGE', 'Bedankt {name}, uw bericht is naar ons verzonden.');
define('INBOX_MESSAGE', 'Naam: {name} {enter} Bedrijf: {company} {enter} E-mail: {email} {enter} Telefoonnummer: {phone} {enter} Onderwerp: {subject} {enter} Bericht: {enter} {comment}');
// Condifureer uw error messages. Let op! Indien gewenst, alleen de tekst veranderen tussen de rode haakjes!
define('ERROR_MESSAGE_NAME', '(U vergeet uw naam in te vullen.)');
define('ERROR_MESSAGE_EMAIL', '(U vergeet uw e-mail in te vullen.)');
define('ERROR_MESSAGE_EMAIL_INVALID', '(Uw email is ongeldig.)');
define('ERROR_MESSAGE_PHONE_INVALID', '(Uw telefoonnummer is ongeldig.)');
define('ERROR_MESSAGE_SUBJECT', '(U heeft geen onderwerp ingevuld.)');
define('ERROR_MESSAGE_COMMENT', '(U heeft geen bericht ingevuld.)');
define('ERROR_MESSAGE_CAPTCHA', '(Voer de juiste code in.)');
define('ERROR_MESSAGE_CAPTCHA_INVALID', '(Probeer de code opnieuw in te voeren.)');
// Script: Aangeraden niet te veranderen!
@ini_set('session.use_cookies', '1');
@ini_set('session.use_trans_sid', 'false');
@session_set_cookie_params(0, '/');
@session_start();
if (ini_get('register_globals')) {
$globals = array('_SESSION');
foreach ($globals as $global) {
foreach ($GLOBALS[$global] as $key => $value) {
if ($value === @$GLOBALS[$key]) {
unset($GLOBALS[$key]);
}
}
}
}
@ini_set('magic_quotes_gpc', 'Off');
if (ini_get('magic_quotes_gpc')) {
function clean($data) {
if (is_array($data)) {
foreach ($data as $key => $value) {
$data[$key] = clean($value);
}
} else {
$data = stripslashes($data);
}
return $data;
}
$_POST = clean($_POST);
}
function php_self(){
if(isset($_SERVER['PATH_INFO']) && strlen($_SERVER['PATH_INFO'])> 0){
return substr($_SERVER['PHP_SELF'], 0, (strlen($_SERVER['PHP_SELF']) - @strlen($_SERVER['PATH_INFO'])));
}else{
return $_SERVER['PHP_SELF'];
}
}
$subjects = explode(',', SUBJECTS);
$error = FALSE;
$send = FALSE;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
$company = $_POST['company'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
$comment = $_POST['comment'];
$captcha = $_POST['captcha'];
$pfind = array(
'+',
'-',
' '
);
$phone_check = str_replace($pfind, '', $phone);
if(empty($name)){
$error_name = ERROR_MESSAGE_NAME;
$error = TRUE;
}
if(empty($email)){
$error_email = ERROR_MESSAGE_EMAIL;
$error = TRUE;
}elseif(!eregi('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$', $email)){
$error_email = ERROR_MESSAGE_EMAIL_INVALID;
$error = TRUE;
}
if(!empty($phone)){
if(!ctype_digit($phone_check)){
$error_phone = ERROR_MESSAGE_PHONE_INVALID;
$error = TRUE;
}
}
if(empty($subject)){
$error_subject = ERROR_MESSAGE_SUBJECT;
$error = TRUE;
}
if(empty($comment)){
$error_comment = ERROR_MESSAGE_COMMENT;
$error = TRUE;
}
if(empty($captcha)){
$error_captcha = ERROR_MESSAGE_CAPTCHA;
$error = TRUE;
}elseif($_SESSION['captcha'] != $captcha){
$error_captcha = ERROR_MESSAGE_CAPTCHA_INVALID;
$error = TRUE;
}
if(!$error) {
if(strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
$ent = "\r\n";
}elseif(strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) {
$ent = "\r";
}else{
$ent = "\n";
}
$find = array(
'{name}',
'{company)',
'{email}',
'{phone}',
'{subject}',
'{comment}',
'{enter}'
);
$replace = array(
'name' => $name,
'company' => $company,
'email' => $email,
'phone' => $phone,
'subject' => $subject,
'commment' => $comment,
'enter' => $ent
);
$comment = str_replace($find, $replace, INBOX_MESSAGE);
$boundary = '----=_NextPart_' . md5(rand());
$headers = 'From: ' . $name . '<' . $email . '>' . $ent;
$headers .= 'X-Mailer: PHP/' . phpversion() . $ent;
$headers .= 'MIME-Version: 1.0' . $ent;
$headers .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . $ent . $ent;
$message = '--' . $boundary . $ent;
$message .= 'Content-Type: text/plain; charset="utf-8"' . $ent;
$message .= 'Content-Transfer-Encoding: base64' . $ent . $ent;
$message .= chunk_split(base64_encode($comment));
ini_set('sendmail_from', $email);
mail(SEND_TO, $subject, strip_tags(html_entity_decode($message)), $headers);
$send = TRUE;
$success = str_replace($find, $replace, SUCCESS_MESSAGE);
}
}
// Eind: Aangeraden niet te verranderen!
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
<head>
<title>Lexperts Contact Form</title>
<meta name="description" content="Lexperts contact form" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div id="box">
<? if($send){ ?>
<div id="success"><h1>Email Sent Successfully.</h1><p><?=$success; ?></p></div>
<? }else{ ?>
<div id="form">
<? if($error) { ?><div class="error"><h1>Invalid Form Input</h1></div><? } ?>
<form method="post" action="<?=php_self() ?>">
<label for="name"><span class="required">* </span>Uw naam:
<? if(!empty($error_name)) { echo '<span class="error_message">'.$error_name.'</span>'; }elseif(!empty($name)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<input name="name" type="text" id="name" size="30" <? if(!empty($name)){ echo 'value="' . $name . '"'; } ?> class="text-input" />
<label for="company">Bedrijf:
<? if(!empty($error_company)) { echo '<span class="error_message>'.$error_company.'</span>'; }elseif(!empty($company)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<input name="company" type="text" id="company" size="30" <? if(!empty($company)){ echo 'value="' . $company. '"'; } ?> class="text-input" />
<label for="email"><span class="required">*</span> Email
<? if(!empty($error_email)) { echo '<span class="error_message">'.$error_email.'</span>'; } elseif(!empty($email)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<input name="email" type="text" id="email" size="30" <? if(!empty($email)){ echo 'value="' . $email . '"'; } ?> class="text-input" />
<label for="phone">Telefoonnummer:
<? if(!empty($error_phone)) {?><span class="error_message"><?=$error_phone?></span><? }elseif(!empty($phone)){ ?><img src="image/icon/accept.png" /><? } ?></label>
<input name="phone" type="text" id="phone" size="30" <? if(!empty($phone)){ echo 'value="' . $phone . '"'; } ?> class="text-input" />
<label for="subject"><span class="required">*</span> Onderwerp:
<? if(!empty($error_subject)) { echo '<span class="error_message">'.$error_subject.'</span>'; } elseif(!empty($subject)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<select name="subject" type="text" id="subject">
<? foreach($subjects as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; } ?>
</select>
<label for="comment"><span class="required">*</span> Bericht:
<? if(!empty($error_comment)) { echo '<span class="error_message">'.$error_comment.'</span>'; }elseif(!empty($comment)){ echo '<img src="image/icon/accept.png" />'; } ?></label>
<textarea name="comment" id="comment" rows="8"><? if(!empty($comment)){ echo $comment; } ?></textarea>
<label for="captcha"><span class="required">*</span> Ben jij een mens?
<? if(!empty($error_captcha)) { echo '<span class="error_message">'.$error_captcha.'</span>'; } ?></label>
<div class="captcha"><img src="captcha.php" /></div>
<input name="captcha" type="text" id="captcha" size="30" class="text-input-captcha" />
<br />
<input type="submit" class="submit" value="Send" />
</form>
</div>
<? } ?>
</div>
</body>
</html>
?>
captcha.php
Code (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
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
<?php
@ini_set('session.use_cookies', '1');
@ini_set('session.use_trans_sid', 'false');
@session_set_cookie_params(0, '/');
@session_start();
if (ini_get('register_globals')) {
$globals = array('_SESSION');
foreach ($globals as $global) {
foreach ($GLOBALS[$global] as $key => $value) {
if ($value === @$GLOBALS[$key]) {
unset($GLOBALS[$key]);
}
}
}
}
header('Content-type: image/png');
$fonts = array ("arial.ttf", "verdana.ttf");
$im = @imagecreate(140, 26)or die("Cannot Initialize new GD image stream");
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 79, 77, 79);
$links = 6;
function generate_captcha($data) {
$value = '';
$charset = 'abcdefghijklmnopqrstuvwxyz1234567890';
$charset_len = strlen($charset) - 1;
srand(microtime() * 1000000);
for ($i=0;$i<$data;$i++)
$value .= $charset{rand(0, $charset_len)};
return $value;
}
for ($q=1; $q < 7; $q++){
$generate_captcha[$q] = generate_captcha(1);
$size = rand (10,14);
$corner = rand (-15,15);
$top = rand (16,20);
$random_font = array_rand($fonts);
imagettftext($im, $size, $corner, $links, $top, $black, 'font/'.$fonts[$random_font], $generate_captcha[$q]);
$links = $links + 20;
}
$_SESSION['captcha'] = $generate_captcha[1] . $generate_captcha[2] . $generate_captcha[3] . $generate_captcha[4] . $generate_captcha[5] . $generate_captcha[6];
imagepng($im);
imagedestroy($im);
?>
@ini_set('session.use_cookies', '1');
@ini_set('session.use_trans_sid', 'false');
@session_set_cookie_params(0, '/');
@session_start();
if (ini_get('register_globals')) {
$globals = array('_SESSION');
foreach ($globals as $global) {
foreach ($GLOBALS[$global] as $key => $value) {
if ($value === @$GLOBALS[$key]) {
unset($GLOBALS[$key]);
}
}
}
}
header('Content-type: image/png');
$fonts = array ("arial.ttf", "verdana.ttf");
$im = @imagecreate(140, 26)or die("Cannot Initialize new GD image stream");
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 79, 77, 79);
$links = 6;
function generate_captcha($data) {
$value = '';
$charset = 'abcdefghijklmnopqrstuvwxyz1234567890';
$charset_len = strlen($charset) - 1;
srand(microtime() * 1000000);
for ($i=0;$i<$data;$i++)
$value .= $charset{rand(0, $charset_len)};
return $value;
}
for ($q=1; $q < 7; $q++){
$generate_captcha[$q] = generate_captcha(1);
$size = rand (10,14);
$corner = rand (-15,15);
$top = rand (16,20);
$random_font = array_rand($fonts);
imagettftext($im, $size, $corner, $links, $top, $black, 'font/'.$fonts[$random_font], $generate_captcha[$q]);
$links = $links + 20;
}
$_SESSION['captcha'] = $generate_captcha[1] . $generate_captcha[2] . $generate_captcha[3] . $generate_captcha[4] . $generate_captcha[5] . $generate_captcha[6];
imagepng($im);
imagedestroy($im);
?>
style.css
Code (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
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
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
body {
background-color: #f6f6f6;
text-align: center; /* IE */
font-family: Helvetica,Arial,sans-serif;
}
#box {
width: 600px;
padding:34px;
padding-top: 40px;
padding-bottom: 40px;
background-color: #ffffff;
margin: 0 auto;
margin-top: 40px;
margin-bottom: 40px;
text-align: left;
border:1px solid #CCCCCC;
-moz-border-radius-bottomleft:10px;
-moz-border-radius-bottomright:10px;
-moz-border-radius-topleft:10px;
-moz-border-radius-topright:10px;
}
textarea, select, .text-input, .text-input-captcha {
width: 350px;
font-family: Helvetica,Arial,sans-serif;
font-size:13px;
color: #333333;
margin-bottom:20px;
margin-top:4px;
padding:10px;
border:1px solid #d6d6d6;
-moz-border-radius-bottomleft:6px;
-moz-border-radius-bottomright:6px;
-moz-border-radius-topleft:6px;
-moz-border-radius-topright:6px;
}
.submit {
font-family: Helvetica,Arial,sans-serif;
font-size:16px;
color: #ffffff;
margin-bottom:20px;
margin-top:5px;
padding:4px 20px;
border:1px solid #459300;
-moz-border-radius-bottomleft:6px;
-moz-border-radius-bottomright:6px;
-moz-border-radius-topleft:6px;
-moz-border-radius-topright:6px;
background-color: #7dbc00;
}
textarea, .text-input, .text-input-captcha {
background-image: url(image/form_bg.jpg);
background-repeat: repeat-x;
}
.input, .text-input {
width:250px;
}
.text-input-captcha {
width:136px;
text-align: center;
}
textarea {
width:500px;
}
label {
display:block;
font-weight:bold;
margin-top:10px;
}
#success h1 {
font-size:24px;
font-weight:bold;
color: #555555;
}
#success p {
font-size:16px;
color: #555555;
}
.error_message {
font-size:12px;
color: #ff4b4b;
font-weight:lighter;
margin-left: 6px;
}
.error h1 {
font-size:24px;
font-weight:bold;
color: #ff4b4b;
}
.required { color: #ff4b4b; }
.captcha {
border:1px solid #d6d6d6;
width: 136px;
height: 26px;
padding:4px;
padding-left: 16px;
margin-top:4px;
-moz-border-radius-bottomleft:6px;
-moz-border-radius-bottomright:6px;
-moz-border-radius-topleft:6px;
-moz-border-radius-topright:6px;
}
background-color: #f6f6f6;
text-align: center; /* IE */
font-family: Helvetica,Arial,sans-serif;
}
#box {
width: 600px;
padding:34px;
padding-top: 40px;
padding-bottom: 40px;
background-color: #ffffff;
margin: 0 auto;
margin-top: 40px;
margin-bottom: 40px;
text-align: left;
border:1px solid #CCCCCC;
-moz-border-radius-bottomleft:10px;
-moz-border-radius-bottomright:10px;
-moz-border-radius-topleft:10px;
-moz-border-radius-topright:10px;
}
textarea, select, .text-input, .text-input-captcha {
width: 350px;
font-family: Helvetica,Arial,sans-serif;
font-size:13px;
color: #333333;
margin-bottom:20px;
margin-top:4px;
padding:10px;
border:1px solid #d6d6d6;
-moz-border-radius-bottomleft:6px;
-moz-border-radius-bottomright:6px;
-moz-border-radius-topleft:6px;
-moz-border-radius-topright:6px;
}
.submit {
font-family: Helvetica,Arial,sans-serif;
font-size:16px;
color: #ffffff;
margin-bottom:20px;
margin-top:5px;
padding:4px 20px;
border:1px solid #459300;
-moz-border-radius-bottomleft:6px;
-moz-border-radius-bottomright:6px;
-moz-border-radius-topleft:6px;
-moz-border-radius-topright:6px;
background-color: #7dbc00;
}
textarea, .text-input, .text-input-captcha {
background-image: url(image/form_bg.jpg);
background-repeat: repeat-x;
}
.input, .text-input {
width:250px;
}
.text-input-captcha {
width:136px;
text-align: center;
}
textarea {
width:500px;
}
label {
display:block;
font-weight:bold;
margin-top:10px;
}
#success h1 {
font-size:24px;
font-weight:bold;
color: #555555;
}
#success p {
font-size:16px;
color: #555555;
}
.error_message {
font-size:12px;
color: #ff4b4b;
font-weight:lighter;
margin-left: 6px;
}
.error h1 {
font-size:24px;
font-weight:bold;
color: #ff4b4b;
}
.required { color: #ff4b4b; }
.captcha {
border:1px solid #d6d6d6;
width: 136px;
height: 26px;
padding:4px;
padding-left: 16px;
margin-top:4px;
-moz-border-radius-bottomleft:6px;
-moz-border-radius-bottomright:6px;
-moz-border-radius-topleft:6px;
-moz-border-radius-topright:6px;
}
Groeten, Stef ter Braak
Graag de code in het vervolg tussen code tags zetten. En zou je er op willen letten dat je enkel relevante code plaatst. Dit zijn 600 regels en weet zo 1,2,3 niet hoeveel mensen dit door gaan spitten voor je.[/modedit]
Gewijzigd op 09/07/2010 10:38:01 door Bas IJzelendoorn
eregi eruit gaat =)
Ik heb niet alles doorgelezen, maar houd rekening dat http://www.phpfreakz.nl/forum.php?forum=1&iid=1326305 is dezelfde vraag gesteld. Daar in ieder geval 1 heel uitgebreid antwoord.
Op Script is gevoelig voor email-injection.