captcha functie werkt niet

Status
Niet open voor verdere reacties.

stienoo

Gebruiker
Lid geworden
31 dec 2007
Berichten
315
Ik heb van een site een captcha functie- gehaald, maar deze werkt niet helemaal.

De code
PHP:
function captcha_generator($code){
error_reporting (E_ALL); // fouten weergeven
$image = imagecreatetruecolor (300, 60); // maakt de image met de groote van 300px breed, en 60px hoog
$aFonts = array ('font1.ttf', 'font2.ttf', 'font3.ttf', 'font4.ttf'); // zet alle beschikbare fonts in een array
$aCode = str_split ($code); // zet alle karakters apart in een array

for ($i = 0; $i < count ($aCode); $i++) // een for-lus maken voor het aantal karakters dat de $aCode array bevat
{
   $fontcolor = imagecolorallocate ($image, // kleurencombinatie maken voor de image variabel ($image)
      rand (190, 255), // rood,
      rand (190, 255), // groen,
      rand (190, 255)); // blauw, deze geven de nieuwe kleur per karakter
   if (count ($aCode) == 4) // de volgende locaties (x-as) aanmaken voor een code van 4 karakters lang
   {
      $pos[0] = rand (15, 55); // locatie aanmaken (x-as) voor de eerste karakter
      $pos[1] = rand (80, 120); // locatie aanmaken (x-as) voor de tweede karakter
      $pos[2] = rand (145, 185); // locatie aanmaken (x-as) voor de derde karakter
      $pos[3] = rand (210, 250); // locatie aanmaken (x-as) voor de vierde karakter
   }
   if (count ($aCode) == 5) // de volgende locaties (x-as) aanmaken voor een code van 5 karakters lang
   {
      $pos[0] = rand (10, 45); // locatie aanmaken (x-as) voor de eerste karakter
      $pos[1] = rand (65, 100); // locatie aanmaken (x-as) voor de tweede karakter
      $pos[2] = rand (120, 155); // locatie aanmaken (x-as) voor de derde karakter
      $pos[3] = rand (175, 210); // locatie aanmaken (x-as) voor de vierde karakter
      $pos[4] = rand (230, 265); // locatie aanmaken (x-as) voor de vijfde karakter
   }
   imagettftext ($image, // image voorbereiden voor de image variabel ($image)
   rand (14, 18), // fontgrootte, willekeurig getal laten kiezen tussen de 13 en 19
   rand (-30, 30), // draaihoek, willekeur getal laten kiezen tussen de -31 en de 31
   $pos[$i], // karakter positie breedte toewijzen, hebben we al voorbereid ($pos[])
   rand (50, 20), // karakter positie hoogte, kiezen tussen de 51 en de 19
   $fontcolor, // fontkleur toewijzen, hebben we al voorbereid ($fontcolor)
   $aFonts[rand (0, 3)], // font, willekeurig font toewijzen uit de array ($aFonts)
   $aCode[$i]); // code toewijzen, op volgorde van de array
}
imagepng ($image, 'captcha.png'); // de .png image aanmaken als captcha.png
imagedestroy ($image); // de handel afronden, en klaar! 
}

De errors:
Code:
Warning: Cannot modify header information - headers already sent by (output started at /home/stienoo/domains/zmz.frih.net/public_html/login/aanmelden.php:13) in /home/stienoo/domains/zmz.frih.net/public_html/login/aanmelden.php on line 44

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/stienoo/domains/zmz.frih.net/public_html/login/aanmelden.php on line 77

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/stienoo/domains/zmz.frih.net/public_html/login/aanmelden.php on line 77

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/stienoo/domains/zmz.frih.net/public_html/login/aanmelden.php on line 77

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/stienoo/domains/zmz.frih.net/public_html/login/aanmelden.php on line 77

Warning: imagettftext() [function.imagettftext]: Could not find/open font in /home/stienoo/domains/zmz.frih.net/public_html/login/aanmelden.php on line 77

Warning: imagepng() [function.imagepng]: Unable to open 'captcha.png' for writing: Permission denied in /home/stienoo/domains/zmz.frih.net/public_html/login/aanmelden.php on line 79
 
headers already sent
Je kan niet headers sturen, omdat je de functie aanroept midden in een pagina.

Je gebruikt een functie, ik zou er een los bestand van maken.... Dna kan je er zoiets van maken:
HTML:
<img src='bla.php?text=hallo'>
als bla.php dan de gewone code bevat, zou het moeten werken.
 
Als het goed is hoef je niet eens ?text= te specificeren

Echter is dit een ander gebruik voor een captcha. Deze zit in een functie... Je zult dus altijd die functie aan moeten roepen, met als resultaat dat je die warnings krijgt...

Handiger is een captcha als deze
PHP:
<?php 
session_start(); 
$width = 140; 
$height = 35; 
$im = imagecreate($width, $height); 
$bg = imagecolorallocate($im, 0, 0, 0); 

// generate random string 
$len = 5; 
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw123456789'; 
$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, 175, 0, 0); 
$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, 130, 0, 0); 
for($i = 0; $i < 30; $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(0, $width - 50); 
$rand_y = rand(0, $height - 15); 
imagestring($im, 10, $rand_x, $rand_y, $string, $text_color); 


header ("Content-type: image/png"); 
imagepng($im); 
?>
Deze kun je dus op de manier zoals Vegras vertelt implementeren.
HTML:
<img src="{naam_van_bovenstaand_script.php}" alt="captcha" />
Omdat deze ook een sessie aanmaakt kun je bij het verwerken van het formulier die gebruiken bij de controle
PHP:
if(md5($_POST['captcha']) != $_SESSION['captcha_code']) {
  echo 'De code komt niet overeen.';
}
Succes :)
 
Laatst bewerkt:
Bedankt, het werkt!!

Ik moet nog wel even de controle uittesten :D

Maar is het hoofdletter gevoelig?
Ik ga het ook wat aanpassen aan mijn stijl :D
 
Ja het is hoofdlettergevoelig.

De controle staat in mijn bericht hierboven (welke ik nu even ga aanpassen aangezien er een klein foutje in zit)
 
Ik heb het allemaal een beetje aangepast, ik heb wat meer kleur erin gebracht en de letterkleur word ook wilikeurig beslist, ik ga ook proberen om te zorgen dat de letters op een andere hoogte komen (nu geen tijd).

De code die ik momenteel heb gemaakt:

PHP:
<?php 
session_start(); 
$width = 140; 
$height = 35; 
$im = imagecreate($width, $height); 
$bg = imagecolorallocate($im, 0, 0, 0); 

// generate random string 
$len = 5; 
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw123456789'; 
$string = ''; 
for ($i = 0; $i < $len; $i++) { 
    $pos = rand(0, strlen($chars)-1); 
    $string .= $chars{$pos}; 
} 
$_SESSION['captcha_code'] = md5($string); 

// grid groen
$grid_color = imagecolorallocate($im, 0, 175, 0); 
$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); 
} 

// grit rood
$extra_color = imagecolorallocate($im, 175, 0, 0); 
$number_to_loop = ceil($width / 15); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $x = ($i + 1) * 15; 
    imageline($im, $x, 0, $x, $height, $extra_color); 
} 
$number_to_loop = ceil($height / 20); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $y = ($i + 1) * 20; 
    imageline($im, 0, $y, $width, $y, $extra_color); 
} 
// grit blouw
$extra2_color = imagecolorallocate($im, 0, 0, 255); 
$number_to_loop = ceil($width / 25); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $x = ($i + 1) * 25; 
    imageline($im, $x, 0, $x, $height, $extra2_color); 
} 
$number_to_loop = ceil($height / 15); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $y = ($i + 1) * 15; 
    imageline($im, 0, $y, $width, $y, $extra2_color); 
} 

// random lines groen
$line_color = imagecolorallocate($im, 0, 130, 0); 
for($i = 0; $i < 10; $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); 
} 

// random lines rood
$line2_color = imagecolorallocate($im, 130, 0, 0); 
for($i = 0; $i < 10; $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, $line2_color); 
}

// random lines blouw
$line3_color = imagecolorallocate($im, 0, 0, 130); 
for($i = 0; $i < 10; $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, $line3_color); 
}

// write the text 
$kleur1 = rand(100, 255);
$kleur2 = rand(100, 255);
$kleur3 = rand(100, 255);
$text_color = imagecolorallocate($im, $kleur1, $kleur2, $kleur3); 
$rand_x = rand(0, $width - 50); 
$rand_y = rand(0, $height - 15); 
imagestring($im, 10, $rand_x, $rand_y, $string, $text_color); 


header ("Content-type: image/png"); 
imagepng($im); 
?>

Veel dank voor de reacties.
 
Ik heb toch even tijd gemaakt :D (Nu heb ik wel nix anders meer kunnen doen vandaag).

Het lijkt nu op een "echte" captcha.
-Je hebt verschillende kleuren in de achtergrond
-Iedere letter heeft een andere kleur
-iedere letter heeft een andere plaats

Hier de code

PHP:
<?php 
session_start(); 
$width = 140; 
$height = 35; 
$im = imagecreate($width, $height); 
$bg = imagecolorallocate($im, 0, 0, 0); 

// generate random string 
$len = 5; 
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw123456789'; 
for ($i = 0; $i < $len; $i++) { 
    $pos = rand(0, strlen($chars)-1); 
    $string[$i] = $chars{$pos}; 
}
for($i=0; $i < $len; $i++){
$string2+=$string[i];
}
$_SESSION['captcha_code'] = md5($string2); 

// grid groen
$grid_color = imagecolorallocate($im, 0, 175, 0); 
$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); 
} 

// grit rood
$extra_color = imagecolorallocate($im, 175, 0, 0); 
$number_to_loop = ceil($width / 15); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $x = ($i + 1) * 15; 
    imageline($im, $x, 0, $x, $height, $extra_color); 
} 
$number_to_loop = ceil($height / 20); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $y = ($i + 1) * 20; 
    imageline($im, 0, $y, $width, $y, $extra_color); 
} 
// grit blouw
$extra2_color = imagecolorallocate($im, 0, 0, 255); 
$number_to_loop = ceil($width / 25); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $x = ($i + 1) * 25; 
    imageline($im, $x, 0, $x, $height, $extra2_color); 
} 
$number_to_loop = ceil($height / 15); 
for($i = 0; $i < $number_to_loop; $i++) { 
    $y = ($i + 1) * 15; 
    imageline($im, 0, $y, $width, $y, $extra2_color); 
} 

// random lines groen
$line_color = imagecolorallocate($im, 0, 130, 0); 
for($i = 0; $i < 10; $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); 
} 

// random lines rood
$line2_color = imagecolorallocate($im, 130, 0, 0); 
for($i = 0; $i < 10; $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, $line2_color); 
}

// random lines blouw
$line3_color = imagecolorallocate($im, 0, 0, 130); 
for($i = 0; $i < 10; $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, $line3_color); 
}

// write the text 
$i=0;
while($i < $len){
$kleur1 = rand(150, 255);
$kleur2 = rand(150, 255);
$kleur3 = rand(150, 255);
$text_color = imagecolorallocate($im, $kleur1, $kleur2, $kleur3);
$rand_x = rand($width/6*$i+15, $width/6*$i+15); 
$rand_y = rand(0, $height - 15); 
imagestring($im, 10, $rand_x, $rand_y, $string[$i], $text_color); 
$i++;
}



header ("Content-type: image/png"); 
imagepng($im); 
?>
 
ik krijg de controle van de captcha niet voor elkaar

stienoo allereerst harstike bedankt voor het captcha script ik heb hem op mijn site er tussen geknutseld maar als ik er willekeurig wat invul krijg ik de mail ook
hieronder mijn script ik krijg het niet voorelkaar kan je mij helpen
PHP:
<?php 
session_start();

// Variabelen:
$voornaam   	= "";    // Naam van de afzender
$achternaam 	= "";
$emailadres 	= "";    // E-mailadres van de afzender
$opmerking     	= "";    // Tekst van het e-mailbericht
$capcode		= "";
$vervuild   	= FALSE; // FALSE als het formulier geen fouten bevat
$verzonden  	= FALSE; // TRUE als het e-mailbericht is verzonden
$melding    	= "";    // String voor (fout)meldingen

// Formulier alleen verwerken als er op een knop met de naam 'submit' is geklikt ...
if (isset($_POST['submit'])) {
    // ... en deze knop de waarde 'Verzenden' heeft:
    if ($_POST['submit'] == "Verzenden") {
        $voornaam       = $_POST['v'];
		$achternaam     = $_POST['n'];
		$emailadres 	= $_POST['e'];
		$opmerking      = $_POST['o'];
		$captcha	    = $_POST['c'];

        // HTML-tags en PHP-code verwijderen:
        $voornaam       = strip_tags($voornaam);
		$achternaam     = strip_tags($achternaam);
		$emailadres 	= strip_tags($emailadres);
		$opmerking      = strip_tags($opmerking);
		$capcode	    = strip_tags($captcha);
		
        // Spaties en andere witruimte verwijderen uit de naam en het e-mailadres,
        // maar niet uit de tekst van het bericht:
       	$voornaam       = trim($voornaam);
		$achternaam     = trim($achternaam);
		$emailadres 	= trim($emailadres);
		$captcha	    = trim($captcha);
		   
	    

        if (strlen($voornaam) < 0) {
            $melding  .= "Voer uw <strong>voornaam</strong> in.<br>";
            $vervuild  = TRUE;
		}
		
		if (strlen($achternaam) < 0) {
            $melding  .= "Voer uw <strong>achternaam</strong> in.<br>";
            $vervuild  = TRUE;
        }
		
		if (strlen($emailadres) < 1) {
            $melding  .= "Voer uw <strong>e-mailadres</strong> in.<br> ";
            $vervuild  = TRUE;
        } else {
            function is_email($emailadres)
{
    // Eerst een snelle controle uitvoeren: 
    // een e-mailadres moet uit minimaal 7 tekens bestaan:
    if (strlen($emailadres) < 7) {
        return FALSE;
    }
    // Daarna een controle met een reguliere expressie uitvoeren:
    if (ereg("^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$", $emailadres)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
            if (!is_email($emailadres)) {
                $melding  .= "<strong>" . htmlentities($emailadres) . "</strong> is geen geldig e-mailadres.<br>";
                $vervuild  = TRUE;
            }
        }

		
		      }
        
        if (strlen($opmerking) < 0) {
            $melding  .= "Voer een <strong>vraag/opmerking</strong> van minimaal <strong>10</strong> karakters in.<br>";
            $vervuild  = TRUE;
        }
		if(md5($_POST['captcha']) != $_SESSION['captcha_code']) {
            $melding  .= "De <strong>code</strong> komt niet overeen.<br>";
            $vervuild  = TRUE;

        }
  
        // E-mailbericht verzenden als de gegevens niet vervuild zijn:
        if (!$vervuild) {
            // Constante voor het e-mailadres van de ontvanger:
            define("AAN", "xxxxxxxxxxxxx.nl");
            // Constante voor het onderwerp:
            define("ONDERWERP", "    ");
            // Headers met de naam en het e-mailadres van de gebruiker:
            $headers  = "From: \"$voornaam $achternaam\" <$emailadres>\r\n";
            $headers .= "Reply-To: \"$voornaam $achternaam\" <$emailadres>\r\n";
            // Naam en e-mailadres toevoegen aan de tekst:
            $tekst .= "\r\nnaam:     $voornaam $achternaam";
			$tekst .= "\r\nadres:    $adres";
			$tekst .= "\r\n          $postcode $woonplaats";
			$tekst .= "\r\nemail:    $emailadres";
			$tekst .= "\r\ntelefoon: $telefoonnummer";
			$tekst .= "\r\nopmerking:";
			$tekst .= "\r\n" ;
			$tekst .= "\r\n$opmerking";
            if (mail(AAN, ONDERWERP, $tekst, $headers)) {
                $verzonden  = TRUE;
                $melding    = "Hartelijk dank voor uw reactie. ";
                $melding   .= "U ontvangt binnen twee werkdagen antwoord. ";
            } else {
                $verzonden  = FALSE;
                $melding    = "Uw bericht kon niet worden verzonden. ";
                $melding   .= "Wijzig het e-mailadres of probeer het later nog een keer. ";
            }
        }
    }
}
// Standaardtekst voor instructies instellen als er geen foutmeldingen zijn:
if ($melding == "") {
    $melding  = "Voer eerst uw voornaam, achternaam, e-mailadres en telefoonnummer in, met evt. uw adres.<br> ";
    $melding .= "Typ daarna uw vraag of omerking in het grote vak, tik de code over en klik op Verzenden.";
}
?>
<?php
include('header.contact.php');	
?>
<hr><p><font color="darkblue"><?php echo $melding; ?></font></p><hr>
<?php
// Formulier weergeven als de gegevens vervuild zijn
// of het e-mailbericht niet verzonden is:
if ($vervuild or !$verzonden) {
    $voornaam       = htmlentities($voornaam);
	$achternaam     = htmlentities($achternaam);
	$adres		    = htmlentities($adres);
    $postcode       = htmlentities($postcode);
	$woonplaats     = htmlentities($woonplaats);
	$emailadres 	= htmlentities($emailadres);
	$telefoonnummer = htmlentities($telefoonnummer);
	$opmerking		= htmlentities($opmerking);
?>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
<table> 
<TD WIDTH="15"><td><label for="v">Voornaam:*</label><td>
<input accesskey="v" id="v" name="v" value="<?php echo $voornaam; ?>"><td>
<label for="n">Achternaam*:</label><td> 
<input accesskey="n" id="n" name="n" value="<?php echo $achternaam; ?>"><td>
</td></tr>
<tr>
<td><td><label for="a">Adres:</label><td>
<input accesskey="a" id="a" name="a" value="<?php echo $adres; ?>"><td>
</td></tr>
<tr>
<td><td><label for="p">Postcode:</label><td> 
<input accesskey="p" id="p" name="p" value="<?php echo $postcode; ?>"><td>
<label for="w">Woonplaats:</label><td>
<input accesskey="w" id="w" name="w" value="<?php echo $woonplaats; ?>"><td>
</td></tr>
<tr><td><td>
<label for="e">Emailadres:*</label><td>
<input accesskey="e" id="e" name="e" value="<?php echo $emailadres; ?>"><td>
<label for="t">Telefoonnummer:*</label><td>
<input accesskey="t" id="t" name="t" value="<?php echo $telefoonnummer; ?>"><td>
</td></tr>
<td><td colspan="4" >
Vraag of opmerking* <br>
<textarea accesskey="o" cols="60" id="o" name="o" rows="4"><?php echo $opmerking; ?></textarea></td>
</td></tr>
<td><td colspan="4" >
Vul hier de code in:*
<tr><td><td><img src="captcha.php" alt="captcha" />
<td>
<label for="c"></label>
<input accesskey="c" id="c" name="c" value="<?php echo $capcode; ?>"></td>
</td></tr>
</table>
<input class="knop" name="submit" type="submit" value="Verzenden"> &nbsp;
<input class="knop" name="submit" type="submit" value="Wissen">
<?php
}
?>


<?php
include('footer.inc.php');	
?>
 
Laatst bewerkt door een moderator:
Dat komt omdat je controle er vanuit gaat dat je het veld van captcha "captcha" hebt genoemd
PHP:
if(md5($_POST['captcha']) != $_SESSION['captcha_code']) {
Maar aangezien jij het veld "c" hebt genoemd gaat dat niet werken.
HTML:
<input accesskey="c" id="c" name="c" value="<?php echo $capcode; ?>"></td>

Dus of de controle aanpassen, of] de name= aanpassen van het veld.
 
controle werkt niet

Als ik wil controleren krijg ik de melding dat het gelukt is maar ik had een foute code ingetikt:(

zou je me iets verder kunnen helpen met dit probleem
het wil me nog niet echt lukken.
of heb je een voorbeeld controle script?

alvast bedankt
 
PHP:
<?php

session_start();

if ( md5 ( $_POST['captcha'] ) != $_SESSION[ 'captcha_code' ] ) { 

  echo "goedzo - u bent geen robot";

} else {

  echo "foei robot, foei foei foei!";

}

?>

En als je een foute code intikt krijg je zeker te zien dat het wel goed is?

Je kijkt of de MD5 van de verzonden string NIET gelijk is aan de waarde in de sessie. Als die NIET gelijk is zeg je goed zo, en anders zeg je foei foei foei. Lijkt me net verkeerd om toch...

Als je van:

PHP:
if ( md5 ( $_POST['captcha'] ) != $_SESSION[ 'captcha_code' ] ) {

nou eens:

PHP:
if ( md5 ( $_POST['captcha'] ) == $_SESSION[ 'captcha_code' ] ) {

maakt. Werkt het dan wel?
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan