FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » script php with <img scr...../>
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: script php with <img scr...../> [message #180222 is a reply to message #180221] Thu, 31 January 2013 19:57 Go to previous messageGo to previous message
J.O. Aho is currently offline  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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: compatibility between php 5.3.21 and 5.3.15 for pgsql
Next Topic: change a string where have number after a word
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 05:54:39 GMT 2024

Total time taken to generate the page: 0.07217 seconds