nigelschal
Gebruiker
- Lid geworden
- 15 sep 2009
- Berichten
- 9
ik heb een vraag , heb hier een formulier , maar hoe krijg ik het voor elkaar om te zorgen dat ie eerst de captcha controleert en daarna pas het formulier verstuurd naar de email adress die staat aangegeven.
Dit is mijn Image.php script
en dit is mijn captcha script
graag wat hulp gewenst
Dit is mijn Image.php script
PHP:
<?php
session_start();
if(isset($_POST['submit'])) {
if(isset($_POST['captcha_code']) && isset($_SESSION['captcha_code'])) {
if(md5($_POST['captcha_code']) == $_SESSION['captcha_code']) {
echo 'Result: CAPTCHA code correct.<br />';
}else{
echo 'Result: CAPTCHA code incorrect.<br />';
}
}else{
if(!isset($_POST['captcha_code'])) {
echo 'Result: No security code was entered.<br />';
}
if(!isset($_SESSION['captcha_code'])) {
echo 'Result: No CAPTCHA was viewed.<br />';
}
}
}
?>
<FORM METHOD='GET' ACTION='http://cgi.StartHotel.dk/cgi-bin/formmail/FormMail.pl'>
<input type=hidden name='print_config' value='name,email'>
<input type=hidden name='recipient' value='nigel@proef80.nl'>
<input type=hidden name='subject' value='From formmail'>
<input type=hidden name='required' value='name,email,message'>
<input type=hidden name='env_report' value='REMOTE_HOST,REMOTE_ADDR, REMOTE_USER,REMOTE_IDENT,HTTP_USER_AGENT'>
<input type=hidden name='sort' value='order:name,zipcode,city,email,subject,message'>
<input type=hidden name='redirect' value='http://www.factortachtig.nl'>
<table cellspacing='2' cellpadding='0'>
<tr>
<td width='52'>name:</td>
<td colspan='2'><input type='text' name='name' size='54'></td>
</tr>
<tr>
<td width='52'>zipcode.:</td>
<td><input type='text' name='zipcode' size='5'></td>
<td align='right'>city: <input type='text' name='city' size='35'></td>
</tr>
<tr>
<td width='52'>Email:</td>
<td colspan='2'><input type='text' name='email' size='54'></td>
</tr>
<tr>
<td width='52'>subject:</td>
<td colspan='2'><input type='text' name='subject' size='54'></td>
</tr>
<tr>
<td width='52' valign='top'>message:</td>
<td colspan='2'><textarea name='message' cols='40' rows='4'></textarea>
</tr>
<tr>
<td><img src="captcha.php" /></td><td><input type="text" name="captcha_code" /></td>
</tr>
<tr>
<td width='52'></td>
<td><INPUT TYPE='submit' name="submit" VALUE='Submit'></td>
</tr>
</table>
</FORM>
en dit is mijn captcha script
PHP:
<?php
session_start();
$width = 155;
$height = 23;
$im = imagecreate($width, $height);
$bg = imagecolorallocate($im, 150, 150, 115);
// genereert een willekeurig getal & Letter.
$len = 5;
$chars = 'ABCDEFGHJKLMNPQRSTUVWXY3456789';
$string = '';
for ($i = 0; $i < $len; $i++) {
$pos = rand(0, strlen($chars)-1);
$string .= $chars{$pos};
}
$_SESSION['captcha_code'] = md5($string);
// grid
$grid_color = imagecolorallocate($im, 200, 150, 85);
$number_to_loop = ceil($width / 20);
for($i = 0; $i < $number_to_loop; $i++) {
$x = ($i + 1) * 20;
imageline($im, $x, 0, $x, $height, $grid_color);
}
$number_to_loop = ceil($height / 10);
for($i = 0; $i < $number_to_loop; $i++) {
$y = ($i + 1) * 10;
imageline($im, 0, $y, $width, $y, $grid_color);
}
// random lines
$line_color = imagecolorallocate($im, 242, 173, 26);
for($i = 0; $i < 20; $i++) {
$rand_x_1 = rand(0, $width - 1);
$rand_x_2 = rand(0, $width - 1);
$rand_y_1 = rand(0, $height - 1);
$rand_y_2 = rand(0, $height - 1);
imageline($im, $rand_x_1, $rand_y_1, $rand_x_2, $rand_y_2, $line_color);
}
// write the text
$text_color = imagecolorallocate($im, 255, 255, 255);
$rand_x = rand(10, $width - 50);
$rand_y = rand(10, $height - 15);
imagestring($im, 18, $rand_x, $rand_y, $string, $text_color);
header ("Content-type: image/png");
imagepng($im);
?>
graag wat hulp gewenst