html - In PHP, how do I use the GD library created image directly on my website -


i'm not sure understand quite how works. website form i'd generate random captcha image , display along form. ideally along lines:

<form action="post.php" method="post">   ...   <?php create_captcha(); ?> </form> 

while have function creates image resource in php (link)

function create_captcha() {   $w = 60; $h = 30;   $img = imagecreatetruecolor($w, $h);   ...   //header("content-type: image/jpeg");   imagejpeg($img); } 

i can't quite figure out how output image directly onto website part of html form. suspicion i'll have save temporary file captcha.jpg , generate <img src="captcha.jpg" /> website.

is there more elegant way without using temporary image?

use captcha generation file path source of img tag

<img src="http://domain.com/your-captcha_generating-file-path" /> 

Comments