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
| //Création d'un code_img
$code_img = '';
for($i=0; $i <= 6; $i++)
{
$rand = mt_rand(1,3);
switch($rand)
{
case 1 : $code_img.=chr(mt_rand(48, 57)); break;
case 2 : $code_img.=chr(mt_rand(65, 90)); break;
case 3 : $code_img.=chr(mt_rand(97, 122)); break;
}
}
header('Content-type: image/png');
$img = imagecreatefrompng('img/fond_code_img.png');
$color = imagecolorallocate($img, 0, 0, 0);
$font = 'img/arial.ttf';
for($i=0; $i <= 6; $i++)
{
$angle = mt_rand(5,25);
if(mt_rand(0,1)==1) $angle = -$angle;
imagettftext($img, 14, $angle, 5+(20*$i), 22, $color, $font, substr($code_img,$i,1));
}
imagepng($img);
imagedestroy($img);[/php]
Je ne sais pas comment insérer se script pour que l'image s'affiche dans le formulaire au bon endroit et que je puisse mettre mon
[php]
<input name="code_img" type="hidden" id="code_img" value="<? echo md5($code_img); ?>"> |
Partager