Re: script php with <img scr...../> [message #180222 is a reply to message #180221] |
Thu, 31 January 2013 19:57 |
J.O. Aho
Messages: 194 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 31/01/13 19:11, sferreira1979(at)gmail(dot)com wrote:
> i have two files: registar_mail.php and captcha.php
> captcha.php display an image witch should appear on my file registar_mail.php using
> <img src="captcha.php"/> but the image doesn't appear :(
> i have been looking for a solution in forums but i don't find anything witch works with me... i'm working with netbeans and xampp
I won't go into the registar_mail.php
> /////script captcha.php//////////////////
> <?php
> //inicia sessão
> session_start();
>
> //definição do tipo de imagem a gerar
> header("Content-type:image/png");
>
> //geração da chave
> $chave=rand(0,500);
>
> //codificação da chave e apresentacao de 8 carateres
> $codigo=substr(sha1($chave),0,8);
>
> $_SESSION['codigo']=$codigo;
>
> //definicao imagem e cor
> $imagem= imagecreatefrompng("imagens/imagemcaptcha.png");
> $cores= imagecolorallocate($imagem, 255, 55, 0);
>
> //centrar código na figura
> imagestring($imagem, 5, 75, 20, $codigo, $cores);
>
> //gerar imagem:Outputs or saves a PNG image from the given image.
> imagepng($imagem);
>
> //DESTRUIR IMAGEM
> imagedestroy($imagem);
>
> ?>
>
> could someone help me to understand what is the problem???
The code itself is okey to add a easy to automatically read text and
generate a new image, the issue may be with the
imagens/imagemcaptcha.png which has to be in a sub directory to the
captcha.php
I do recommend you use a professional solution for captcha, take a look
at this one:
http://www.google.com/recaptcha
--
//Aho
|
|
|