Bonjour,

Je suis en train d'essayer de faire un captcha visuel (donc avec une image) mais je n'arrive pas à voir l'image sur ma page HTML (des le premier chapitre du tuto), il m'affiche que le nom de l'image.

Il me dise d’installer la librairie GD, mais avec la version d’easyphp l’extension dans le php.ini est activer (j’ai enlevé le . Faut-il faire autre chose ?


Voici mes codes :
Formulaire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<html>
<head>
</head>
<body>
 
    <?php session_start(); ?>
 
	<form action="verification.php" method="post">
	<p>
 
		<label for="nom">Votre nom</label>
			<input type="text" name="nom" id="nom" /><br />
 
		<label for="captcha">Recopiez le mot : <img src="captcha.php" alt="Captcha" /></label>
			<input type="text" name="captcha" id="captcha" /><br />
 
		<input type="submit" value="envoyer" />
	</p>
	</form>
 
</body>
</html>
Le fichier vérification :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
<<?php session_start(); ?>
<?php
 
if((!empty($_POST['captcha'])) && (!empty($_POST['nom'])))
{
	if($_POST['captcha'] == $_SESSION['captcha'])
		echo 'Le captcha est bon, votre nom est '.$_POST['nom'];
	else
		echo 'La captcha n\'est pas bon.';
}
else
	echo 'Il faut remplir tous les champs.';
?>
Et le dernier le plus important captcha :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?php session_start(); ?>
	<?php
function nombre($n)
{
	return str_pad(mt_rand(0,pow(10,$n)-1),$n,'0',STR_PAD_LEFT);
}
 
 
function image($mot)
{
	$largeur = strlen($mot) * 10;
	$hauteur = 20;
	$img = imagecreate($largeur, $hauteur);
	$blanc = imagecolorallocate($img, 255, 255, 255); 
	$noir = imagecolorallocate($img, 0, 0, 0);
	$milieuHauteur = ($hauteur / 2) - 8;
	imagestring($img, 6, strlen($mot) /2 , $milieuHauteur, $mot, $noir);
	imagerectangle($img, 1, 1, $largeur - 1, $hauteur - 1, $noir); // La bordure
 
	imagepng($img);
	imagedestroy($img);
 
}
 
 
function captcha()
{
	$mot = nombre(5);
	$_SESSION['captcha'] = $mot;
	image($mot);
}
 
header("Content-type: image/png");
captcha();
 
	?>
Aidez moi s'il vous plait.
Cordialement
Poucet Benjamin