title: Problem with inserting an image in a form using GD!
body: <p>I'm trying to develop a captcha class for my website everything was doing fine until I tried to embed the image generated with PHP GD inside my subscription form!</p>
  
  <p>Here is the code of my class:</p>
  
  <pre><code>&lt;?php
  //captcha.php
  header("Content-type: image/png");
  
  
  class Captcha  {
  
  
    // some attributes bla bla
  
    public function __construct($new_string_length,$new_width_picture,
                                $new_height_picture,$new_string_color) {
  
      $this-&gt;string_length = $new_string_length;
      $this-&gt;width_picture = $new_width_picture;
      $this-&gt;height_picture = $new_height_picture;
      $this-&gt;string_color = $new_string_color;
  
    }
  
    public function getString() {
      return $this-&gt;string;
    }
  
    public function generateRandomString() {
      $str = "";
      $basket = "abcdefghijklmnopqrstuvwxyz0123456789";
      $basket_length = strlen($basket);
      srand ((double) microtime() * 1000000);
      for($i=0;$i&lt;$this-&gt;string_length;$i++) {
  
          $generated_pos = rand(0,$basket_length);
          $str_substr = substr($basket,$generated_pos-1,1);
          if(!is_numeric($str_substr)) { 
            // if the character picked up isn't numeric
            if(rand(0,1)==1) {
              // we randomly upper the character
              $str_substr = strtoupper($str_substr);
            }
          }
          $str = $str.$str_substr;
      }
  
      $this-&gt;string = $str;
    } 
  
    **public function generatePictureFromString($new_string) {
        $root_fonts = '../fonts/';
        srand ((double) microtime() * 1000000);
        $list_fonts = array('ABODE.ttf','acme.ttf','Alcohole.ttf',
                     'Anarchistica.ttf','AMERIKAA.ttf');
  
        $image = @imagecreatetruecolor($this-&gt;width_picture,$this-&gt;height_picture);
        $noir  = imagecolorallocate($image,0,0,0);
        $clr = explode('/',$this-&gt;string_color);
        $clr = imagecolorallocate($image,$clr[0],$clr[1],$clr[2]);
  
  
  
  
        for($i=0;$i&lt;strlen($new_string);$i++) {       
             imagettftext($image,rand(($this-&gt;height_picture/4.3),($this-&gt;height_picture)/4.2),
             rand(-45,45),($this-&gt;width_picture)/(5*$this-&gt;string_length)+($this-&gt;width_picture)/($this-&gt;string_length)*$i,0.6*($this-&gt;height_picture),$clr,
             $root_fonts.$list_fonts[rand(0,count($list_fonts)-1)],substr($new_string,$i,1));
        }
  
        imagepng($image);
        imagedestroy($image);
  
    }**
  
  }
  </code></pre>
  
  <p>I willingly avoided to show some useless part of the class. The class itself works perfectly when I call the generatePictureFromString(..) method like this:</p>
  
  <pre><code>&lt;?php
  //testeur_classe.php
  require_once '../classes/captcha.php';
  
  $captcha = new Captcha(5,200,80,"255/255/255");
  $captcha-&gt;generateRandomString();
  $str  = $captcha-&gt;getString();
  $captcha-&gt;generatePictureFromString($str); 
  ?&gt;
  </code></pre>
  
  <p>But when I try to insert the picture generated in my form using:</p>
  
  <pre><code>&lt;img src="&lt;?php echo PATH_ROOT.'classes\testeur_classe.php'; ?&gt;"/&gt;
  </code></pre>
  
  <p>nothing is displayed!</p>
  
  <p>How am I supposed to do that ?</p>
  
  <p>Thank you!</p>