Captcha
jameskougar
Messages postés
74
Statut
Membre
-
bg62 Messages postés 23524 Date d'inscription Statut Modérateur Dernière intervention -
bg62 Messages postés 23524 Date d'inscription Statut Modérateur Dernière intervention -
Bonjour,
J'ai suivi un tutoriel pour créer un captcha et le problème c'est que l'image n'est pas affiché lorsque je teste le formulaire. Est ce que quelqu'un pourrait m'aider s'il vous plait?
Merci d'avance
J'ai suivi un tutoriel pour créer un captcha et le problème c'est que l'image n'est pas affiché lorsque je teste le formulaire. Est ce que quelqu'un pourrait m'aider s'il vous plait?
Merci d'avance
<?php
session_start();
function genPWD ($int_min, $int_max=0) {
mt_srand();
if ($int_max != 0) $longueur = mt_rand($int_max, $int_min);
else $longueur = $int_min;
$mdp = '';
for($i=0; $i<$longueur; $i++){
$quoi= mt_rand(1,3);
switch($quoi){
case 1: $mdp .= mt_rand(0,9); break;
case 2: $mdp .= chr(mt_rand(65,90)); break;
case 3: $mdp .= chr(mt_rand(97,122)); break;
}
}
return $mdp;
}
function generate_captcha()
{
putenv('GDFONTPATH=' . realpath('.'));
$pwd = array();
$final = array();
mt_srand();
for($i=0;$i<mt_rand(500,1000);$i++)
{
$pwd[] = genPWD(6,8);
}
while(count($final)<6)
{
mt_srand();
$value = mt_rand(0,count($pwd));
if(!in_array($pwd[$value],$final))
{
$final[] = $pwd[$value];
}
}
mt_srand();
$nb = mt_rand(0,5);
$texte = 'Veuillez choisir ';
$texte2 = 'le code écrit en rouge.';
$img = imagecreate(220,150);
$bg = imagecolorallocate($img,255,255,255);
$txt = imagestring($img,5,10,10,$texte,imagecolorallocate($img,0,0,0));
$txt = imagestring($img,5,10,23,$texte2,imagecolorallocate($img,0,0,0));
$i = 0;
$font = 'kmkdspt';
foreach($final as $key => $value)
{
if($key == $nb)
{
$color = imagecolorallocate($img,200,0,0);
$return = $value;
}
else
{
$color = imagecolorallocate($img,0,0,0);
}
if( ($i%2) == 0)
{
$txt = imagettftext($img,14,15,20,80+($i*13),$color,$font,$value);
}
else
{
$txt = imagettftext($img,14,15,110,80+(($i-1)*13),$color,$font,$value);
}
$i++;
}
imagepng($img);
return $return;
}
$_SESSION['code'] = generate_captcha();
?>
A voir également:
- Captcha
- Kijiji captcha - Télécharger - Outils professionnels
- Jdownloader captcha - Guide
- Captcha impossible à valider ✓ - Forum Mozilla Firefox
- Captcha carte grise ✓ - Forum Réseaux sociaux
- Probleme doctolib captcha ne fonctionne pzs - Forum Réseaux sociaux
1 réponse
vois ici:
https://www.commentcamarche.net/faq/19213-php-code-antispam-avec-chiffres-et-lettres-captcha
et:
https://www.unesourisetmoi.info/pages/captchapage.php
:-)
https://www.commentcamarche.net/faq/19213-php-code-antispam-avec-chiffres-et-lettres-captcha
et:
https://www.unesourisetmoi.info/pages/captchapage.php
:-)